SCAN protocol: preventing instruction drift in long sessions (~300 token overhead)
Problem
Long system prompts (CLAUDE.md, CODEX.md, AGENTS.md) lose effectiveness as conversation grows. A 1000-token system prompt that was 50% of attention at start becomes ~1% after an hour. Models progressively ignore rules, constraints, and formatting — especially dangerous for billing, auth, and architecture decisions.
Prompt repetition and session restarts don't fix this because they don't address the core issue: attention decay over the attention mechanism.
SCAN Protocol — a working solution
We've been running a protocol called SCAN in production (multi-agent system, 11 agents, 100K+ token sessions) that solves this. The core idea:
Force the model to generate answers about its instructions before starting work. Output tokens create fresh attention links to the system prompt — passive re-reading doesn't.
7 question markers scattered across different sections of the system prompt. To answer each, the model must read that section. This costs ~300 tokens for a full scan, ~120 for a mini scan (<0.5% overhead at 100K context).
How it works
- Place
@@SCAN_1through@@SCAN_7at the end of key instruction sections - Each marker is a task-relevant question (e.g., "Which components does this task affect?", "What's easiest to violate here?")
- Before work: model outputs 1-2 sentence answers per marker — in visible output, not thinking
- After work:
CHECK(what was verified) +MISSED(what was skipped and why) - Between subtasks: one-line
ANCHORrefresh to pull attention back
Triggers: !!! = full scan, !! = mini scan, automatic classification for everything else.
Results
Without SCAN: critical rules forgotten by mid-session. With SCAN: stable compliance across entire session, CHECK/MISSED catches gaps before deployment. One prevented production bug justifies thousands of scans.
Full writeup + reference implementation
Gist with complete protocol, cost analysis, multi-agent setup, and limitations:
https://gist.github.com/sigalovskinick/c6c88f235dc85be9ae40c4737538e8c6
Why this matters for Claude Code / Codex
Anyone with a long CLAUDE.md or CODEX.md faces the same problem — model reads it at start, forgets 80% by the third tool call. SCAN is a lightweight, zero-infrastructure solution that could be built into the default compact/context system, or at least documented as a recommended pattern.
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗