Context Rot
Context rot is the drop in an LLM's accuracy as its input grows, even well inside the context window. Covers the evidence, causes, and fixes.
Context rot is the decline in accuracy of a large language model (LLM) as its input grows longer, even when the input fits well inside its context window. A model that answers correctly from a 300-token prompt can miss the same fact, follow an outdated instruction, or mix up similar details once that fact sits among 100,000 tokens of conversation history, documents, and tool output. Chroma's July 2025 context rot report measured the effect on 18 models from Anthropic, OpenAI, Google, and Alibaba, including Claude Opus 4, GPT-4.1, Gemini 2.5 Pro, and Qwen3, and found accuracy falling with input length on every model, even on a task as simple as copying a long list of repeated words.
How Context Rot Shows Up#
Simple retrieval tests hide it. In a needle in a haystack (NIAH) test, the inserted fact usually shares words with the question, and frontier models now score near 100% at hundreds of thousands of tokens. Harder tests expose the decline:
- Position: The 2023 study Lost in the Middle found that models answer best when the relevant passage sits at the start or end of the prompt and worst when it sits in the middle.
- Task complexity: NVIDIA's RULER benchmark adds multi-hop tracing and aggregation tasks and found that only half of 17 models claiming 32K tokens or more performed satisfactorily at 32K.
- No literal match: NoLiMa phrases each question with minimal word overlap with the answer, so the model has to infer the link. At 32K tokens, 11 of 13 models fell below half of their short-context scores, and GPT-4o dropped from 99.3% to 69.7%.
- Distractors and memory: In Chroma's tests, a single passage similar to the answer lowered accuracy, and on LongMemEval conversation questions every model scored much higher with focused prompts of about 300 tokens than with full histories of about 113,000 tokens.
Why It Happens#
Self-attention spreads a fixed amount of softmax weight across every token, so each added token competes with the evidence that matters, a limit Anthropic calls the model's attention budget. Models also learn their attention patterns from training data in which short sequences are more common than long ones, and older instructions, superseded facts, and near-duplicate passages give the model several plausible answers to choose from. Structure matters too: in Chroma's tests, haystacks of shuffled, incoherent sentences hurt accuracy less than coherent essays.
Context Rot vs. Related Terms#
- Context window: The hard limit on how many tokens a model accepts. Context rot happens below that limit.
- Hallucination: Any output not supported by the input or facts. Long, distracting prompts raise its rate, and in Chroma's distractor tests GPT models hallucinated most often while Claude models more often declined to answer.
- Catastrophic forgetting: Loss of earlier skills when training changes a model's weights. Context rot changes no weights and happens at inference time.
- Data drift: A shift in the inputs a deployed model receives over time.
Reducing Context Rot#
The fix is context engineering: putting the smallest set of relevant tokens in front of the model on every call. Retrieval-augmented generation (RAG) with semantic chunking and a reranker sends a few relevant passages in place of whole document sets, and prompt compression shortens what remains. Anthropic's guide to context engineering for AI agents adds three techniques for long tasks: compaction, which replaces old turns with a summary; structured notes the AI agent writes outside the window and reads back later, a form of episodic memory; and sub-agents that explore with tens of thousands of tokens in their own windows and return summaries of 1,000-2,000 tokens.
Agent skills apply the same just-in-time loading to instructions. In Ultralytics Agent Skills, a yolo router skill maps a request to one of six lifecycle skills, such as yolo-training or yolo-export, so a coding agent loads detailed YOLO guidance only for the stage it is working on.










