License YOLO
Back to Ultralytics Glossary

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 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.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Turn drone and aerial imagery into real-time insights for agriculture, aquaculture, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Apply computer vision in aerospace with Ultralytics YOLO for aircraft inspection, runway FOD detection, airport ground operations, and composite defect detection.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning