Series 1 of 4 · Agentic Stack · Level 1 · Topic 04

Context Rot

Context Engineering
In This Note You Will Learn
  • 01. Why more tokens in the context window often produces worse responses -- and the four mechanisms that cause quality to degrade invisibly.
  • 02. The "pre-rot threshold" at 50-60% capacity where quality starts declining faster than you can add value -- and how to measure it for your product.
  • 03. Why Anthropic found that resetting context with precise information outperforms compressing accumulated context -- and how to design reset points into your pipeline.
  • 04. How to design explicit reset points into a production pipeline so the model never operates in a rotted state.

The Story

Anthropic's own internal finding flipped the engineering instinct: for long-running tasks, resetting the context beats compressing it. A legal-tech contract-review assistant for corporate counsel showed why. The system worked section by section through long contracts, accumulating analysis as it went — party names, obligations, risk flags, unusual clauses. By the end of a 40-page contract, it had built up a comprehensive context. By the end of a 200-page master services agreement, that context was rotting in place.

The problem emerged on complex commercial agreements. By the time the assistant reached sections 25-40, its analysis quality had measurably declined. It started contradicting its own earlier findings. It confused parties -- attributing Supplier's obligations to Buyer. It missed risk flags in later sections that were identical to flags it had caught in earlier sections.

Then an associate ran an experiment. She took sections 30-40 from a problematic contract and ran them through the assistant as a fresh session -- without the accumulated analysis from sections 1-29. The quality was excellent. Same sections, same model, same prompts -- but without 28,000 tokens of accumulated prior analysis.

The assistant's context had rotted. Not because any individual piece of information was wrong, but because the accumulated volume had pushed the system past the point where additional context helped.

The Core Idea

Context rot is the progressive degradation of AI output quality as the context window fills with accumulated information over time. It's the hidden failure mode of every AI product that maintains state across multiple interactions.

Context rot is to AI products what technical debt is to software. Both are invisible accumulations that degrade quality over time. Both feel manageable in the moment. Both become crises when they cross a threshold.

-- The working analogy

Four mechanisms drive context rot. Attention dilution -- the model's attention spreads thinner as tokens increase. Information conflict -- long conversations accumulate contradictory signals. Staleness -- data loaded 30 minutes ago may be obsolete. Noise accumulation -- pleasantries, dead-end explorations, and failed tool calls compete for attention with substantive content.

Fig 1. The Rot Curve
More Context Is the Enemy
of Better Context.
More tokens. Worse answers. The cliff is real.
0-30% fill 95% Fresh Context Every token earning its place. Full attention budget available.
30-55% fill 88% Optimal Range Slight degradation but still production-grade. Operate here.
55-75% fill 76% Active Rot Attention fragments. Middle content dissolves. Most teams don't notice.
75-100% fill <65% Critical Rot Contradictions, hallucinations, format breaks. The model is drowning.
Pre-Rot Threshold at 50-60% -- cross this line and quality degrades faster than you can add value.
Day 1
Clean board, clear plan
Day 2
Notes added, still readable
Day 3
Overlapping scrawl, key items buried
Day 4
Illegible. Someone erases and starts fresh.
The rot is invisible at first. By the time you notice bad output, you've been in the rot zone for thousands of tokens.

Where This Hits in Production

Long-running agent workflows. An AI agent researching, drafting, then reviewing accumulates context at each step. By the review step, the window contains all prior work. The review happens with degraded attention. Anthropic's guidance: design explicit context reset points between phases rather than carrying accumulated state.

Customer support conversations. A support AI handling a complex issue over 20+ turns accumulates the full conversation history. By turn 20, attention to the original problem statement is diluted. The AI starts repeating suggestions.

Document processing pipelines. Any AI product that processes long documents section by section accumulates analytical context that eventually degrades analysis quality. Sections processed last get worse treatment than sections processed first.

!

The Trap

Compressing everything instead of resetting.

When context grows too large, the default engineering response is to build a compression pipeline. Summarize the history. Extract key entities. Create a compact representation. The dashboard looks better.

What they lose: the specific phrasing of the user's constraint, the exact number from a tool result that the summary rounded, the nuanced exception mentioned in passing. Summaries are lossy. The lost details are the exact ones that cause production failures.

The fix: design explicit reset points. Between phases of a workflow, between topics, between documents. Fresh context with precise information beats compressed context with smoothed edges.

In Practice: Reset vs. Compress

Here's the contract review assistant redesigned with explicit reset points -- and the results.

Fig 2. Same Task, Same Model, Different Architecture
The Fix Isn't Compression.
It's a Clean Start.
Continuous Context -- One Long Session
Phase 1 · 91%
Phase 2 · 82%
Phase 3 · 71%
Phase 4 · 64%
Final: 64% accuracy $1.14 per document
Reset-Based -- Four Clean Contexts with Handoffs
Phase 1 · 94%
22% fill
Phase 2 · 93%
24% fill
Phase 3 · 92%
26% fill
Phase 4 · 93%
23% fill
Final: 93% accuracy $0.89 per document
200-token structured summary passed between each phase
+29 accuracy points -22% cost 4 resets vs. 1 long run
Same task, same model, same data. The only difference: when to start fresh.

Remember This

1. More tokens does not mean better answers. Context rot degrades quality through four mechanisms -- attention dilution, information conflict, staleness, and noise accumulation -- and it sets in at roughly 50-60% of capacity, not at 100%.

2. Resetting beats compressing. For task-critical information, starting fresh with precisely selected context produces better outcomes than summarising accumulated context. Summaries lose the edges. The edges are where the failures live.

3. Context rot means you're paying for tokens that make your product worse. Managing context is not just quality engineering -- it is cost engineering. Frame it that way to your CFO and the investment gets approved faster.

Connecting the Dots

Context rot is to AI products what technical debt is to software. Both are invisible accumulations that degrade quality over time. Both feel manageable in the moment ("we'll clean it up later"). Both become crises when they cross a threshold. Both require proactive design to prevent -- not reactive cleanup once the damage is visible.

The eval connection. When an AI product fails an eval, the diagnostic discipline from The CONTEXT Stack points at one of the seven layers. Context rot is a different diagnosis. The layers are correctly assembled, the window correctly populated -- the failure comes from how much is in there, not what. A team that knows context rot exists asks two questions on every failure: which layer is missing or wrong? and is the context volume past the pre-rot threshold?

On the autonomy spectrum. At Levels 1-3, context rot is annoying -- the user notices and starts a new conversation. At Levels 5-7, context rot is dangerous. An autonomous agent making decisions on a rotted window might take actions informed by stale data, contradictory instructions, or attention-diluted reasoning. The agent does not know its context has rotted. It operates with the same confidence at 90% capacity as it did at 30% -- but the quality of its decisions has degraded measurably and silently.

The harness as the answer. This is why the harness exists as a discipline. The harness is the system that wraps the model and manages context lifecycle so the model never has to operate in a rotted state -- monitoring volume, triggering resets at designed thresholds, and selecting what carries forward across a phase boundary. The model stays sharp because the system around it keeps the context clean. See What is a Harness.

References

1. Context Engineering for AI Agents -- Anthropic Engineering Blog

2. Lost in the Middle: How Language Models Use Long Contexts -- Liu et al., NeurIPS 2023

3. Building Effective Agents -- Anthropic Engineering Blog

4. Chroma Research: Long Context Performance -- Chroma

Previous Topic Back to the Deep Dive