Context Rot
Context rot is the drop in a model's ability to recall information as its context window fills. More tokens can mean worse use of each one.
Context rot is what happens as a model's context window fills up: its ability to accurately recall information from that context goes down. Anthropic's engineering team describes it as a finding from needle-in-a-haystack style benchmarks, and says it appears across all models, with some degrading more gently than others.
Why it matters
Context rot means a bigger window is not automatically better. The same post describes an attention budget that every new token draws on, and calls context a finite resource with diminishing returns. Paste in everything and the one constraint that matters competes with thousands of tokens that don't.
What to do about it
The answer is context engineering: finding the smallest set of high-signal tokens for the task. In a coding agent that means:
- Keep instruction files short. Anthropic recommends under 200 lines per CLAUDE.md.
- Load reference material on demand, through search, path-scoped rules, or skills.
- Send large research tasks to subagents, which return only a summary.
- Compact long sessions with a focus, so the summary keeps what matters.
For how Claude Code applies each of these, see context engineering for coding agents and Claude Code. For the cost side, see how to reduce Claude Code token usage.
For how this differs from prompt writing, see context engineering vs prompt engineering.
- What is context rot?
- The decline in a language model's ability to accurately recall information from its context as the number of tokens in the window grows. Anthropic's engineering team describes it as emerging across all models, with some degrading more gently than others.
- Does a bigger context window fix context rot?
- No. A bigger window holds more, but recall still degrades as it fills. Anthropic's guidance is to treat context as a finite resource and find the smallest set of high-signal tokens for the task.
- How do coding agents deal with context rot?
- By loading less and loading it later: short instruction files, retrieving files just in time with search, path-scoped rules, subagents that work in their own window, and compaction that summarizes long sessions.
Related