Context rot
The quality drop that shows up late in a long session, as a conversation fills with stale plans, dead ends, and superseded file contents. The model starts contradicting itself or re-solving solved problems; the fix is usually a fresh session seeded with a clean summary, not a longer explanation.
At a glance
- Shows up
- Late in long sessions
- Cause
- Stale and contradictory material in context
- Typical sign
- Re-fixing bugs that were already fixed
- Fix
- Fresh session plus a clean summary
- Prevention
- Smaller, separately scoped tasks
How it works
Every message, file read and tool result stays in the conversation. After an hour of work that history holds three versions of the same file, an abandoned plan, error output from a bug that is already fixed, and corrections to mistakes the agent no longer makes. The model has no reliable way to tell which of these is current, so it weighs all of them.
The window does not have to be full for this to happen. Quality often slips well before the hard limit, because the useful signal becomes a shrinking share of what the model reads. Typical signs: the agent reintroduces a bug it fixed, patches a file from an old version of it, or cites a plan you rejected.
Why it matters
Long sessions feel productive because the agent has seen so much, but past a point every extra correction makes things worse. Recovery is cheap: start a new session seeded with the goal, what is done, what is left and the decisions that must hold. Keep durable facts in files (the agents file, a spec, the ticket) so a fresh session can pick them up without the noise. Built-in compaction such as Claude Code's /compact helps, but check the summary, since it can carry the confusion forward.
Context rot vs. hallucination
A hallucination is the model stating something false, and it can happen on the first message. Context rot is specific to long sessions: the errors come from outdated material that really is in context. Hallucination calls for verification; context rot calls for a cleaner context.
It is also distinct from simply running out of window. Hitting the limit is a hard stop the harness has to handle; context rot is a gradual decline that happens while everything still technically fits, which is why it is easy to miss until the output is clearly wrong.
Example
Goal: add CSV export to the reports page.
Done: `exportCsv()` in src/lib/export.ts, unit tests passing.
Left: wire the button in ReportsHeader, add an e2e test.
Keep: dates are ISO 8601 in UTC; do not add a new dependency.Common mistakes
- Explaining the same correction a third time instead of restarting with a clean summary.
- Assuming a bigger context window makes a long session safe to keep extending.
- Trusting an automatic compaction summary without checking that it dropped the abandoned plans.
In Fredrin
Fredrin gives each ticket exactly one agent session in its own branch and worktree, so one task's history never leaks into another's.
How Workers runRelated terms
Frequently asked questions
Does a bigger context window prevent context rot?
Not on its own. A larger window delays the hard limit, but stale and contradictory material still degrades answers long before the window is full.
Should I compact or start a new session?
Compact when the session is on track and just long. Start fresh with your own summary when the agent is repeating mistakes, since a compacted summary can preserve the confusion.