Context Rot
Why answers get worse as a conversation with an AI assistant grows, how to recognise it, and how to recover with handoff summaries and notes files.
On this page
Context rot is the gradual drop in answer quality that happens when a conversation with a language model gets long and fills up with material that is no longer true or no longer relevant. It matters to anyone who works with an assistant for hours at a time, because the symptoms look like the model getting worse, when the actual cause is the text you keep sending it.
In a long session the assistant starts to forget a rule you gave it early on, bring back a fix you already rejected, or edit an old version of a file instead of the latest one. Once you can recognise this, the remedy is usually to start a new session with a short summary, not to keep correcting the old one.
Why long sessions degrade
On every call, the assistant reads the whole context again: every message, every reply and every tool result so far. Nothing is removed unless you or the application removes it, so a long session carries all of its history into every reply, and quality can drop well before the context limit is reached. That has four consequences.
Dead ends stay in the context
An approach you abandoned is still there in full detail. It looks as authoritative as the approach you kept, and the model has no reliable way to know which one you meant unless you said clearly that the first one failed. A long failed attempt can also be far more detailed than the one-line message that rejected it.
Old versions pile up
If three drafts of the same function are in the context, a request such as "change the function so it also handles empty input" may be applied to the wrong draft, or to a blend of two of them.
Early instructions get less weight
A rule from message 3 sits under everything that came after it. Models tend to use information in a very long context less reliably than information in a short one, as described in The Context Window. When the conversation reaches the limit, the application may also drop the oldest messages, and that is exactly where your rules usually are.
Earlier mistakes become examples
The model continues the text it is given, and that text includes its own earlier wrong replies. A mistake that appeared three times in the history is more likely to appear a fourth time, because the history now shows it as normal.
An example of a session rotting
The tracer below follows a debugging session. The token counts are made up for illustration. "Current" means the text that still applies, and "share" is current divided by total.
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 (fix the date bug) and the rule that tests must pass. Everything in the context is current.
- context0goal + rules1attempt A
- total
- 1000
- current
- 1000
- share
- 100%
2Attempt A rewrites the date parser and adds 800 tokens. At this point it is the plan, so it counts as current.
- context0goal + rules1attempt A2error log
- total
- 1600
- current
- 200
- share
- 13%
3Attempt A fails and the 600-token error log is added. Both are now history, but both stay in full, so only the 200 tokens of goal and rules still apply.
- context0goal + rules1attempt A2error log3keep API
- total
- 1700
- current
- 300
- share
- 18%
4You add a new rule, "keep the public API the same", because attempt A had changed it. This is a 100-token message, and it is easy to overlook next to the 800 tokens of attempt A.
- context0goal + rules1attempt A2error log3keep API4attempt B
- total
- 2500
- current
- 1100
- share
- 44%
5Attempt B works and adds 800 tokens. The current material is the goal, the API rule and attempt B, which is 200 + 100 + 800 = 1,100 tokens.
- context0goal + rules1attempt A2error log3keep API4attempt B5tangent
- total
- 3100
- current
- 1100
- share
- 35%
6A 600-token side discussion about logging is added. Nothing in it is needed, so the current share falls to about a third.
- context0goal + rules1attempt A2error log3keep API4attempt B5tangent
- total
- 3100
- current
- 1100
- share
- 35%
7You ask for one more change. The reply borrows from attempt A, which changes the public API, because A is still in the context and contains a lot of detail to copy.
- context0handoff1attempt B
- total
- 1050
- current
- 1050
- share
- 100%
8In a fresh session you paste a 250-token handoff (goal, API rule, and "attempt A failed because it changed the API") plus attempt B's code. Everything in it is current, and the context is about a third of the size. Attempt A's 800 tokens are gone, but one line still tells the model not to retry it.
Signs that a session has rotted
One of these on its own can have other causes, such as an unclear request. Two or more together are a strong sign of rot.
- The assistant forgets or breaks a rule that you set early in the session.
- It brings back an approach or a bug that you already rejected.
- It edits an old version of the work instead of the latest one.
- You are writing more corrections than new requests.
- Replies become longer, vaguer and more hedged.
When you see several of them, change the context instead of arguing with the assistant. Further corrections only add more text to the context that is causing the problem.
How to recover and prevent it
Start a fresh session with a handoff
Ask the assistant to summarise the session, read the summary and correct it, then paste it into a new conversation. A useful handoff contains the goal, the current state of the work, the decisions and rules that apply, the approaches that failed and the reason each one failed, and the next step. This is the most reliable fix, because the new session contains only current material.
Keep a notes file
For work that lasts several days, keep the handoff in a file such as NOTES.md. Load it at the start of each session and update it whenever you reach a milestone. Some coding tools load a file like this automatically. It works as memory that you control, because you decide what is in it and you can read it.
# 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.Edit your message instead of adding a correction
If a bad reply was caused by an unclear message, most chat tools let you edit that message and regenerate the reply. The bad reply then leaves the context, which is better than adding a correction after it, because the correction leaves the bad reply in place for the model to read.
Use one session for each task
Open a new conversation when the topic changes. The side question about logging in the example above would have been better asked in its own chat, where it could not add 600 tokens of unrelated text to the debugging session.
Repeat rules that a late request depends on
If a request near the end of a long session depends on a rule from the beginning, state the rule again in that request. It costs one sentence and does not rely on the model weighing a distant message correctly.
Keep bulky material out of the main session
Large pasted files, long logs and big search results are the fastest way to fill a context with text that is only needed once. Do the work that needs them in a separate conversation, or in a sub-task that has its own context, and bring back only the conclusion. Some agent tools do this with sub-agents.
Automatic compaction
Some applications do part of this for you. Near the context limit they replace older turns with a summary and may clear old tool results. This helps, but the summary is written by the model, and it decides what to keep. A rule that mattered to you may be left out, so for important work a handoff that you wrote or checked is more dependable.
Pitfalls
After 60 messages planning a team offsite, replies are getting muddled. Here is what happened, in no 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
This handoff puts the decisions and constraints first. Each rejected option keeps one line with its reason, so the new session will not suggest Porto or the first two hotels again. The T-shirt discussion is left out because it does not affect any later step, and the handoff ends with one clear task to start on.
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 the most useful for a fresh session?
A project spans two weeks of sessions. What keeps each new session on track with the least effort?
What to practise next
The next time a session drifts, write the handoff, start a fresh session and compare the first reply with the last one from the old session. Then read What Is an Agent, where a model runs long tool loops on its own and managing the context becomes a central part of the design.