Skip to main content
BVDNET
Arnhem · websites & automationBVDNET
Core Concepts

Context rot

Context rot is the decline in an AI model's work as its conversation or task grows longer, so that it starts to overlook instructions and facts from earlier on.

Also known as: context degradation, context pollution

Context rot is the decline in an AI model's work as the text it has to keep in view grows: earlier messages, pasted documents and the results of tools it used. The longer that gets, the more likely the model is to overlook an instruction or a fact. A chatbot that follows your house style at the start of a long session can drift away from it later.

Where does the term come from?

Chroma, the company behind the vector database of the same name, used it in a technical report of 14 July 2025, Context Rot: How Increasing Input Tokens Impacts LLM Performance (Kelly Hong, Anton Troynikov, Jeff Huber). They tested 18 models, including GPT-4.1, Claude 4, Gemini 2.5 and Qwen3, on deliberately simple tasks, and performance became less reliable as the input grew. In September 2025 Anthropic took up the term in Effective context engineering for AI agents: as the number of tokens in the context window increases, the model recalls information from it less accurately. Some models degrade more gently than others, but it happens in all of them.

What did the research find?

  • In a question-answering test on chat histories, every model did much better with only the relevant part (about 300 tokens) than with the full history of about 113,000 tokens, most of it irrelevant.
  • Performance fell faster when the question and the answer were less similar in meaning, and a single distractor, a passage on the same topic that does not answer the question, already lowered the score.
  • Models did better when the surrounding text was shuffled than when it read as a coherent essay, a result Chroma calls surprising.
  • Earlier work, Lost in the Middle (Liu et al., 2023), found that models use information at the start and end of a long input better than information in the middle.

Why does it happen?

Chroma leaves the mechanism open. Anthropic gives two explanations. In a transformer every token can attend to every other token, so n tokens have n² pairwise relationships, and the model's attention gets stretched thin as the context grows. Models are also trained mostly on shorter sequences, so they have less experience with dependencies that span a long context. Anthropic calls the result an attention budget: every new token uses up some of it.

How do you prevent it?

Anthropic's post describes these techniques:

  • Compaction: summarise a conversation that nears the limit and continue in a fresh context with the summary. Its lightest form clears old tool results. Claude Code does this automatically, which is why its documentation advises keeping lasting rules in CLAUDE.md.
  • Structured note-taking: the agent writes notes to a file outside the context, such as a to-do list, and reads them back later.
  • Sub-agents: focused subtasks run in clean context windows and return a short summary, often 1,000 to 2,000 tokens.
  • Just-in-time loading: the agent keeps references such as file paths and loads the data only when it needs it.

Community tools for Claude Code package these ideas. According to their READMEs of May 2026, GSD gave each executor a fresh context and claimed to solve context rot, Context Mode kept raw tool output in a sandbox outside the context, and Claude Mem compressed session memory so it survives across sessions. See also context compression.

Example

Suppose a developer tells a coding agent in the morning never to touch the payment module. By the afternoon the session holds dozens of test runs and file listings, and the agent edits the payment module anyway. The rule is still in the context, buried under tool output. Putting it in CLAUDE.md, clearing old tool results or handing the searching to a sub-agent keeps it in view.