# What Is Context Rot? Why AI Agents Degrade Mid-Session


URL: https://getunblocked.com/blog/what-is-context-rot/
Published: 2026-08-10T15:00:00Z
Author: Dennis Pilarinos
Categories: Context Engineering, AI Agents

Context rot is the drop in LLM output quality as context grows. See why it starts long before the window fills, and why 96% of devs don't fully trust AI output.

---
Context rot is the gradual degradation of an LLM's output quality as its context grows — the model starts missing, misreading, or ignoring information that is still right there in the window. It sets in long before the window is full, and it is the usual reason an agent that felt sharp for the first hour starts fumbling in the second. Nothing broke, and no data was lost. The model is simply using its own context worse than it did at the start of the session.

## What is context rot?

Context rot is the decline in a model's ability to accurately use information already sitting in its context window as the token count grows. Instructions get dropped and recall turns fuzzy even though every relevant token remains technically available to the model.

The term came out of long-context recall research and has since become standard engineering vocabulary; Anthropic's own model documentation now defines it by name. It is distinct from hallucination, which is fabrication and can happen at any context length, and from model staleness, which is about training data ending at a cutoff date. Rot is specific to what happens inside a single growing session.

It matters because degraded output has a human price. In Sonar's 2026 State of Code survey of more than 1,100 developers, [96% said they do not fully trust AI-generated code, and only 48% always verify it before committing](https://www.sonarsource.com/blog/state-of-code-developer-survey-report-the-current-reality-of-ai-coding/). A rotting session produces exactly the kind of output that deepens that verification burden.

## Why does context rot happen?

Attention is a budget. A transformer relates every token in the window to every other token, and the attention any single fact receives shrinks as the pool grows. Anthropic's [context window documentation](https://platform.claude.com/docs/en/build-with-claude/context-windows) is blunt about the consequence: more context is not automatically better, because accuracy and recall degrade as token count climbs. The window is working memory, and working memory gets crowded.

Position matters too. Models are trained mostly on shorter sequences, so they weight the beginning and end of the window more reliably than the middle. Material buried mid-window, like the design decision from forty minutes ago or the constraint stated once inside a long file dump, is the first to fade. OpenAI's [prompt engineering guidance](https://developers.openai.com/api/docs/guides/prompt-engineering) likewise recommends keeping the content you reuse across requests at the beginning of the prompt.

Then there is noise. A long agent session accumulates stale tool output and abandoned approaches, all of it competing for attention with the tokens that actually matter.

## What does it look like in an agent session?

The symptoms are easy to recognize once you map them to their causes:

- Forgotten instructions. Rules from your instruction file stop being applied mid-session. That is mid-window loss: the rules are still present, but attention has moved elsewhere.
- Contradicted decisions. The agent agreed to an approach an hour ago and now argues for the opposite, because the original discussion has faded.
- Repeated work. It re-reads files or re-runs checks it already completed, a sign its recall of session history has degraded.
- Confident misquotes. It describes a function or config it read earlier and gets the contents wrong while sounding certain.
- Trial-and-error drift. Precise, reasoned edits give way to guess-and-check loops as reasoning quality drops.

Bloated instruction files accelerate all of this, because [every preloaded rule spends attention budget before real work begins](https://getunblocked.com/blog/audit-fix-bloated-claude-md/). And the burden lands on people: The Register's coverage of the Sonar survey notes that [95% of developers spend at least some effort reviewing AI output, and 59% rate that effort moderate or substantial](https://www.theregister.com/software/2026/01/09/devs-doubt-ai-written-code-but-dont-always-check-it/4932910).

## Frequently asked questions

### Why does my agent get worse the longer it runs?

Because every turn adds tokens, in the form of tool output, diffs, and logs, and every added token dilutes the attention available to everything else. Small per-step errors then stack rather than average out, which is why 2026 work [toward a science of AI agent reliability](https://arxiv.org/pdf/2602.16666) proposes measuring agents on consistency and robustness across runs alongside single-attempt success. Session length itself is the risk factor.

### Does a bigger context window fix it?

No. A larger window raises the ceiling on how much you can load, but degradation begins well before any advertised limit, so extra capacity mostly gives the decay more room to operate. The fuller answer is in the next section.

### Is context rot the same as hallucination?

No. Hallucination is fabrication: the model invents information it never had, and it can occur in a ten-line prompt. Rot degrades the model's handling of information it does have, and it worsens with length. They do interact: a rotted session hallucinates more, because weak recall gets papered over with plausible invention.

### Can you fix it by restarting the session?

Partly. A fresh session drops the accumulated noise, but it also drops legitimate context, including the decisions and constraints you established along the way. Teams square this with retrieval on demand, using a context engine such as Unblocked to pull the relevant history back in when it is needed instead of hoping the window still holds it.

## Does a bigger context window fix context rot?

Advertised windows keep growing; [Anthropic's current models accept up to a million tokens](https://platform.claude.com/docs/en/about-claude/models/overview). Effective context has not kept pace. Output quality degrades well before the advertised limit, which is why practitioners treat effective context as a fraction of the number on the spec sheet rather than the number itself.

For agents, the problem compounds. Suppose degradation drags an agent from near-perfect down to 85% reliability on each individual step. Run ten dependent steps and the chance of a clean end-to-end run is 0.85 to the tenth power, roughly 20%. That is only arithmetic, but it explains why long sessions fail in slow motion. It is also why [2026 evaluation research argues that single-attempt benchmarks hide how agents decay across long horizons](https://arxiv.org/pdf/2603.29231).

A bigger window lets you load more, and that is all it does. What fits in the window and [what the model can actually use are different questions](https://getunblocked.com/blog/claude-code-context-window/).

## Is context rot the same as running out of context?

No, and glossaries routinely blur the two. Running out of context is overflow: the session hits the window's hard limit and something visible happens, such as truncation, a compaction pass, or an error. Rot is quieter. It happens mid-window, with room to spare and every token still present; the model just uses them worse.

| Context overflow | Context rot |
| --- | --- |
| Session hits the hard token limit | Window still has room to spare |
| Old content is truncated or summarized away | All content is still present in the window |
| Announces itself with warnings or errors | Silent; visible only as declining quality |
| Managed by trimming or splitting sessions | Managed by curating what enters at all |


The distinction changes the remedy. Overflow is a capacity problem you can schedule around. Rot is a quality problem that starts the moment the window begins filling, which is why the fixes below focus on curation rather than compression.

## Where does it hit hardest?

Long-horizon coding agents, by a wide margin. An agentic loop stacks tool output on tool output: file reads, diffs, test logs, shell results. Most of it is single-use noise the moment the step completes, yet all of it stays in the window. Sessions that run for hours accumulate exactly the conditions rot needs.

Tooling overhead makes it worse. Connect a handful of MCP servers and [their schemas can consume a meaningful slice of the window before the first real task token arrives](https://getunblocked.com/blog/mcp-tool-overload/). The budget gets spent on plumbing.

This tracks the broader reliability picture: the [International AI Safety Report 2026](https://arxiv.org/abs/2602.21012) treats the dependable behavior of general-purpose AI systems as an open scientific problem. If you run Claude Code, we have a field guide to [context rot in Claude Code specifically](https://getunblocked.com/blog/context-rot-claude-code/), including where in a session it tends to bite.

## How do teams prevent it?

Four categories of mitigation hold up across tools:

Curate what enters. Prune instruction files down to the rules the agent actually violates without them. Trim tool inventories and schemas. Treat every preloaded token as attention already spent.

Reset at phase boundaries. Finish planning, then start implementation in a fresh session that carries forward a short summary instead of the full transcript. You keep the conclusions and shed the noise.

Isolate side tasks. Send research and exploratory work to a separate session or subagent so its intermediate output never pollutes the main thread. Only the distilled answer comes back.

Retrieve on demand. Instead of preloading everything an agent might need, fetch what it needs at the moment it needs it. This is where a context engine fits: Unblocked, the context engine for engineering, resolves the relevant PR thread, doc, or past decision when the question comes up, so the window carries answers rather than archives.

Getting agents to manage this budget themselves is an active research area; [Self-GC](https://arxiv.org/pdf/2607.00692), from 2026, has agents governing their own context on long-horizon tasks.

## How to spot it in your own sessions

Run a quick three-item self-check on any session that has been running for a while:

1. The agent re-asks questions you already answered.
2. It contradicts a decision the two of you settled earlier.
3. Output quality falls off a cliff right after a long stretch of tool output or file dumps.

Any one of these means the window is working against you, and the answer is rarely a bigger model or a bigger window. Rot is a curation problem, not a capacity problem: sessions stay sharp when the context contains what the current step needs and little else. That discipline can be manual, or it can come from tooling that retrieves context on demand, which is [the job we built Unblocked to do](https://getunblocked.com/blog/inside-the-unblocked-context-engine/).