Context Rot
Why long AI sessions slowly get worse, how to spot it, and how to recover with handoff summaries, fresh sessions and a notes file.
On this page
A team spends a whole day in a planning workshop. By five o'clock the whiteboard holds three versions of the timeline, a budget everyone rejected at lunch, and arrows to ideas that were crossed out but not erased. Someone walking in could not tell which plan is current. Even the people who were there start quoting the rejected budget.
Long sessions with an AI assistant go the same way. The first hour is sharp. Two hours and a hundred messages later, it forgets a rule you set early on, brings back a fix you already rejected, and mixes the old version of your code with the new one. The context has rotted.
Why long sessions degrade
Every message, every attempt and every tool result stays in the context and is reread on each call. As the session grows, several things happen at once.
- Dead ends stay. A wrong approach you abandoned is still there, in full, looking just as authoritative as the right one. The model cannot tell which one you gave up on unless that is clearly said.
- Old versions pile up. Three drafts of a function or an email sit in the context. Asked to change "the function", the model may edit the wrong one or blend them.
- Early instructions fade. A rule from message 3 is now a tiny share of a huge context, buried under everything said since. As The Context Window showed, models tend to use a long context less reliably than a short one, and near the limit the app may trim the rule away entirely.
- Mistakes become examples. If the model made the same error twice earlier, those replies are now part of the text it continues. It tends to keep the pattern.
Watch it happen
A developer fixes a bug with an assistant. The token counts are made up. Track how much of the context is still current.
each turn: context += new message + replynothing is ever removedfresh session: context = handoff + current code- context0goal + rules
- total
- 200
- current
- 200
- share
- 100%
1The session starts with the goal and the rules: fix the date bug, tests must pass. Everything in the context is current.
- context0goal + rules1attempt A
- total
- 1000
- current
- 1000
- share
- 100%
2The assistant proposes attempt A, a rewrite of the date parser (800 tokens). For now, it is the current plan.
- context0goal + rules1attempt A2error log
- total
- 1600
- current
- 800
- share
- 50%
3Attempt A fails, with a 600-token error log. A is now a dead end, but its full text stays in the context.
- context0goal + rules1attempt A2error log3keep API
- total
- 1700
- current
- 900
- share
- 53%
4The developer adds a constraint: "Keep the public API the same." Attempt A had changed it, which is another reason it was rejected.
- context0goal + rules1attempt A2error log3keep API4attempt B
- total
- 2500
- current
- 1100
- share
- 44%
5Attempt B works. The error log is now resolved history. Current material: goal, constraint and attempt B, 200 + 100 + 800 = 1,100 tokens.
- context0goal + rules1attempt A2error log3keep API4attempt B5tangent
- total
- 3100
- current
- 1100
- share
- 35%
6A 600-token tangent about logging, unrelated to the bug. Current share drops to about a third.
- context0goal + rules1attempt A2error log3keep API4attempt B5tangent
- total
- 3100
- current
- 1100
- share
- 35%
7The developer asks for one more change. The reply borrows from attempt A, the version that changed the API, because A is still sitting there with plenty of detail to copy.
- context0handoff1attempt B
- total
- 1050
- current
- 1050
- share
- 100%
8Fresh session. It starts with a 250-token handoff (goal, the API rule, "attempt A failed: changed the API") plus attempt B's code. All of it is current, and the context is a third of the size.
The handoff kept one line from the dead end: that it failed, and why. That line stops the fresh session from trying it again. The 800 tokens of A's code are gone.
Signs your session has rotted
- It forgets or breaks a rule you set early on.
- It brings back an approach or a bug you already rejected.
- It edits an old version of something instead of the latest.
- You are writing more corrections than requests.
- Replies get longer, vaguer, and more hedged than at the start.
Two or more together mean it is time to change the context, not argue.
What to do about it
- Start fresh with a handoff. Ask the assistant for a short summary, correct it yourself, and paste it into a new chat. A good handoff has the goal, the current state, the decisions and rules, what was tried and failed with the reason, and the next step.
- Keep a notes file. For work that spans days, keep the handoff in a file outside the chat: a project brief or a
NOTES.mdnext to your code. Load it at the start of each session and update it at each milestone. Some coding tools load such a file automatically. It is memory that you control. - Edit instead of piling on. If a reply went wrong because of your message, many apps let you edit that message and regenerate. The bad reply leaves the context instead of staying as an example.
- Split the work. One task per session. A tangent about logging deserves its own chat.
- Restate what matters. When a late request depends on an early rule, repeat the rule in the request. It costs one sentence.
# Date bug fix: notes
Goal: dates entered as DD/MM must not be read as MM/DD.
Rules: keep the public API unchanged. All tests must pass.
Current state: parser fixed in parseDate() (attempt B). Tests pass.
Tried and failed:
- Rewriting the parser (attempt A): changed the public API.
Next: add tests for 29 Feb and for two-digit years.Some apps do part of this for you, often called compaction: when a session nears its limit, older turns are replaced by a summary, and old tool results may be cleared. It helps, but the summary decides for you what matters, so read it for important work.
Common mistakes
Try it yourself
You have spent 60 messages planning a team offsite with an assistant, and replies are getting muddled. Here is what actually happened, in no particular order. Write a handoff for a fresh session in under 120 words.
- Porto was considered, then dropped because flights were too expensive. Lisbon was chosen.
- Dates: 12 to 14 May. Budget: 400 per person, 9 people.
- Three people are vegetarian.
- Hotel 1 was over budget. Hotel 2 had no meeting room. Hotel 3 has not replied yet.
- A long side discussion about team T-shirts went nowhere.
- Next: chase Hotel 3, then draft a day-by-day agenda.
Show a sample answer
Why it works: the decisions and constraints come first, each dead end keeps one line with its reason so it is not retried, and the T-shirt tangent is gone. It ends with a single clear next task, so the fresh session starts working instead of recapping.
Check yourself
Late in a long session, the assistant keeps reusing an approach you rejected an hour ago. What is the most likely cause?
Which handoff summary is most useful for a fresh session?
Your project spans two weeks of sessions. What keeps each new session on track with the least effort?
What to practise next
Next time a session starts to drift, write the handoff and start fresh, and compare the next reply. Then move on to What Is an Agent, where a model runs long tool loops on its own and managing context becomes the core of the design.