Context rot is the drop in an LLM’s accuracy as its input gets longer. In a coding agent the session starts sharp and gets sloppier, well before the window is full. The cause is noise as much as length: old logs, stale files and failed attempts. Keep context short and clean with focused sessions, handoff notes and compression that removes noise, not signal.
What is context rot?
A 2025 Chroma report found frontier models getting worse on simple tasks as input grew. Agents feel it more than chat, because every file, test run and grep is re-sent on every step.
- default
- with condense
Signs your coding agent has context rot
If these appear after an hour and vanish in a fresh session, it is context rot, not a worse model.
| Symptom | What is usually behind it |
|---|---|
| Ignores a rule you gave early on | The rule is buried mid-context under newer turns |
| Re-reads a file it already read | The earlier read is stale or hard to find |
| Retries a fix that already failed | The failure is in context but not salient, or was compacted away |
| Edits based on old code | Several versions of the same file are in context |
| Slower, vaguer answers | More text to reason over, less of it relevant |
Why long context degrades LLMs
- Lost in the middle. The 2023 paper showed models recall the start and end of an input best. Your turn-5 instructions drift into the middle.
- Distractors. The old version of a function or a fixed bug’s stack trace looks relevant and does more harm than unrelated text.
- Attention is finite. A 2,000-line test log can crowd out a one-line constraint.
- Summaries lose detail. Auto-compact fixes length but can drop the decisions you needed. See /compact vs /clear.
Context rot is not the same as a full context window
You can have plenty of free space and still be too noisy to work well. For the hard limit, see Claude Code context window full.
| Full context window | Context rot | |
|---|---|---|
| Kind | Hard limit | Soft decline |
| How you see it | /context | Answer quality |
| When it starts | At the window size | Long before that |
How to tell context rot from a model problem
Before switching models or rewriting the prompt, run a quick test. It hurts most in long debugging loops, multi-file refactors and multi-step migrations.
- 1Write the state to a file
Have the agent summarize the task and where it stands.
- 2Start fresh with only that file
Give the new session the same next step.
- 3Compare
If it gets it right, the context was the problem. If not, fix the task or the instructions.
How to prevent context rot
- 1One task per session
/clearwhen you move on. Cheapest and most effective. - 2Hand off, do not drag on
A short state file (done, broken, ruled out, next step), clear, continue.
- 3Keep standing rules out of chat
CLAUDE.md and AGENTS.md load at the top of every request. Keep them short.
- 4Isolate exploration
A subagent searches in its own context, so the main session never sees the dead ends.
- 5Cut noisy tool output
Failing tests, log tails, scoped searches. See tool output is eating your context.
- 6Remove noise continuously
Decide what the model sees each step: context engineering.
Compression that removes noise, not signal
condense never rewrites the system prompt, your messages or final answers, and keeps the recent working set verbatim. Helene trims new content without touching code, patches or errors; Adeline summarizes only loops the session has moved past.
On one 200-turn coding session in our quality evaluation, condense held trajectory quality with 62% fewer tokens. Below about 20 turns the benefit does not cover the overhead.
Frequently asked questions
Why does Claude Code get dumber in long sessions?
The model has more to attend to and more of it is stale. Accuracy falls with length and distracting content, even far from a full window.
What is lost in the middle?
A 2023 finding that models use the start and end of a long input more reliably than the middle. Early instructions in a long session drift into that middle.
Does a bigger context window prevent context rot?
No. It postpones running out of space, not the quality drop.
Why does my AI agent forget earlier instructions?
A compaction dropped them, or newer noise buried them. Put rules that must hold in CLAUDE.md or AGENTS.md, which load fresh on every request.
Can context compression make context rot worse?
Yes, if it removes a tool result the agent still needs. Good compression drops redundant and finished content and keeps code, errors and the recent working set.