Blog

What is context rot? Why coding agents get worse

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.

92.0%
CoQA accuracy on Helene 1's compacted context
30.6%
of input tokens removed
62%
fewer tokens on a 200-turn session, quality held

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.

Context carried per turn
Illustrative session
auto-compactturn 1turn 40
  • default
  • with condense
An agent session keeps piling up stale material until auto-compact. Compression keeps the pile smaller the whole way.

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.

SymptomWhat is usually behind it
Ignores a rule you gave early onThe rule is buried mid-context under newer turns
Re-reads a file it already readThe earlier read is stale or hard to find
Retries a fix that already failedThe failure is in context but not salient, or was compacted away
Edits based on old codeSeveral versions of the same file are in context
Slower, vaguer answersMore 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 windowContext rot
KindHard limitSoft decline
How you see it/contextAnswer quality
When it startsAt the window sizeLong 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.

  1. 1
    Write the state to a file

    Have the agent summarize the task and where it stands.

  2. 2
    Start fresh with only that file

    Give the new session the same next step.

  3. 3
    Compare

    If it gets it right, the context was the problem. If not, fix the task or the instructions.

How to prevent context rot

  1. 1
    One task per session

    /clear when you move on. Cheapest and most effective.

  2. 2
    Hand off, do not drag on

    A short state file (done, broken, ruled out, next step), clear, continue.

  3. 3
    Keep standing rules out of chat

    CLAUDE.md and AGENTS.md load at the top of every request. Keep them short.

  4. 4
    Isolate exploration

    A subagent searches in its own context, so the main session never sees the dead ends.

  5. 5
    Cut noisy tool output

    Failing tests, log tails, scoped searches. See tool output is eating your context.

  6. 6
    Remove 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.

CoQA accuracy
Same questions, full vs compacted context
full transcript
90.0%
Helene 1
92.0%
Removing 30.6% of input tokens raised accuracy. From Helene 1.

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.

All posts