Est.

Context Rot in AI Agents: Why Agents Get Worse as Their Context Grows

Nothing in the context is wrong, and the window is nowhere near full, yet the agent gets less reliable with every step. That is context rot. Here is how to recognize it in a trace, prove it with a replay and engineer around it.

By Failure Mode Weekly Editors · November 27, 2026

Context rot is the drop in a model's accuracy as the number of tokens in its context grows. It starts long before the advertised context window is full, it happens on tasks the same model gets right with a short input, and no single piece of content is to blame. The length and shape of the context is the problem.

For agents this is not an edge case. An agent appends every plan, tool call and tool result to its history, so each step reasons over a longer context than the one before. A failure that shows up at step 40 may be a step that would have worked at step 4.

Where the term comes from

The name comes from Chroma's July 2025 technical report, “Context Rot: How Increasing Input Tokens Impacts LLM Performance”. Its authors tested 18 models, including GPT-4.1, Claude 4, Gemini 2.5 and Qwen3, on deliberately simple tasks, and held each task constant while changing only the amount of input. Their summary:

Across all experiments, model performance consistently degrades with increasing input length.

— Context Rot: How Increasing Input Tokens Impacts LLM Performance, Chroma

Anthropic's engineering guide to context engineering for agents adopted the term and gave the working definition most teams now use: “as the number of tokens in the context window increases, the model's ability to accurately recall information from that context decreases.” It describes context as a finite “attention budget” that every new token draws down.

What the research found

Each finding below maps onto something agents do every run.

  • Meaning-based lookups rot faster than exact matches. In Chroma's tests, the less a question's wording overlapped with the passage that answered it, the faster accuracy fell as input grew. Agents rarely search their history with the exact words they wrote it in.
  • Near-misses hurt more as context grows. A single distractor, text that is related to the answer but is not it, lowered accuracy, and four lowered it further. The effect grew with input length. In an agent, earlier failed attempts and similar-looking tool results are distractors.
  • Focused input beats full input. On LongMemEval conversations, every model family did significantly better given only the relevant part (around 300 tokens) than the full history (around 113,000 tokens) containing the same answer.
  • Advertised windows overstate usable context. NoLiMa tested 13 models that claim at least 128K tokens of context with questions that share few words with their answers. At 32K tokens, 11 of them fell below half of their short-context scores.
  • Position can matter. “Lost in the Middle” found models often did best when the relevant information was at the start or end of the input and worse when it sat in the middle. Chroma saw no notable position effect on its own retrieval task, so treat position as something to test on your workload, not a fixed rule.
  • Long outputs rot too. Asked to copy back a sequence of repeated words, models made more mistakes as the sequence grew. An agent's own long outputs are part of the context the next step reads.

Context rot vs. the failures it gets mistaken for

FailureWhat is wrongTypical trace sign
Context rotNothing in the context is false or missing; there is simply too much of it for the model to use wellStep quality falls as tokens per call rise, and the failing step succeeds when replayed with only the context it needs
Context poisoningA false claim got into the context and later steps treat it as factA claim no tool output supports keeps being cited, and a shorter context does not fix it
Context distractionThe history is long enough that the model repeats past actions instead of planningThe same tool calls repeat as the context grows; a loud form of context rot
Overflow and truncationThe window did fill, and content was cut to fitA fact present early in the run is absent from the input of later calls
Instruction driftInstructions are still in the context but lose their pull over a long runRules followed early in the run are broken later, without any prompt change
Tool overloadToo many tool definitions crowd the contextWrong tool picked or wrong arguments from the first step, before any history builds up

The quickest way to separate them: rot is about quantity, poisoning is about a false claim, truncation is about missing content. If the failing step works when you replay it with less context and nothing else changed, it is rot. For the deeper mechanics of reasoning quality falling before the window fills, read over-stuffed context windows causing reasoning compression.

Why agents rot faster than chats

  • Append-only history. Unless the harness removes anything, every step's messages, tool calls and results stay in the context for the rest of the run.
  • Raw tool results. Full file contents, API responses, HTML pages and logs go in whole, though the agent usually needed one line of them.
  • Failed attempts stay in. Retries, errors and abandoned plans remain beside the eventual right answer, which makes them exactly the near-miss distractors the research found most damaging.
  • Tool definitions. A large tool registry is a long block of similar-looking text loaded on every call.
  • Memory loaded by default. Long-term memory and retrieved documents added “just in case” lengthen every call whether or not the step needs them.

Signs of context rot in a trace

  • Failures cluster late in long runs, while short runs of the same task succeed.
  • The agent asks for, or re-fetches, something it already has earlier in the context.
  • A detail from an early tool result is answered wrongly, though it is present in the input of the failing call.
  • The agent acts on an earlier, superseded result instead of the latest one, with both in the context.
  • Tool arguments get sloppier as the run goes on: missing fields, wrong types, values from the wrong record.
  • Steps per task rise after a change that added context (more tools, more memory, longer instructions) while the success rate stays flat or falls.
  • Splitting the same task into a fresh session at the midpoint fixes it.

How to confirm it is context rot

  1. Record tokens per call. Your trace needs the input token count of every model call, and ideally the assembled input itself. Without it you cannot see the context growing.
  2. Line up outcomes against context size. Across many runs, compare the share of steps that went wrong at different input sizes. Rot shows up as an error rate that rises with input size, not with step type.
  3. Check the answer was there. For the failing step, confirm the fact or instruction it needed is in its input and is correct. If it is missing, look at truncation; if it is wrong, look at poisoning.
  4. Replay with a focused context. Replay the failing call with only what that step needs: the task, the current state and the one relevant tool result. If it now succeeds and the full-context replay still fails, you have rot. See controlled replay for isolating agent failure causes.
  5. Find what to cut. Remove blocks of the context one at a time (old tool results, failed attempts, unused tool definitions, memory) and replay again to see which removal restores the step. That block is your first fix.

Fixes that keep context rot down

LeverWhat it doesWatch out for
Tool result clearingDrops or shortens old raw tool results once the agent has used themKeep a reference (an ID or path) so the agent can fetch the result again if needed
CompactionSummarizes a long history and restarts with the summarySummaries drop evidence; a wrong conclusion in one becomes context poisoning
Structured notesThe agent writes progress and decisions to a store outside the context and reads back only what it needsGate what gets written; see missed memory writes and silent context loss
Just-in-time retrievalKeeps lightweight references in context and loads the content only when a step needs itSlower than loading everything up front; retrieval quality now matters more
Sub-agentsRuns focused subtasks in their own clean context and returns a short resultHand-offs can lose information; see handoff failures in multi-agent pipelines and why multi-agent systems fail
Fewer tools per callLoads only the tool definitions the current step could useThe selection logic is now part of the harness and needs its own tests
Remove failed attemptsDeletes superseded plans, errors and retries once a step succeedsKeep them in the trace for debugging, just not in the model's input
Token budgets and alertsCaps input size per step and alerts when runs grow past itSet the cap from your own replay results, not from the model's advertised window

Whichever lever you pull, validate it against the production traces that showed the rot, and check it did not break tasks the agent already handled. Trimming context can delete something a later step needed. See replay-based eval workflows for validating agent changes before shipping.

The size at which rot becomes a problem depends on the model, the task and how the context is laid out, so no published number will tell you your limit. Measure it on your own traces, and measure it again when you change models.

A short checklist

  • Does your trace record the input token count, and the assembled input, of every model call?
  • Do you know the input size at which your agent's step error rate starts to climb?
  • Are raw tool results cleared or shortened once they have been used?
  • Are failed attempts and superseded plans removed from the model's input?
  • Does each step get only the tool definitions it could use?
  • Is memory loaded when a step needs it, rather than on every call?
  • Can you replay a failing step with a focused context to confirm rot before changing anything?

Sources

  1. Context Rot: How Increasing Input Tokens Impacts LLM Performance
  2. Effective context engineering for AI agents
  3. NoLiMa: Long-Context Evaluation Beyond Literal Matching
  4. Lost in the Middle: How Language Models Use Long Contexts
  5. LongMemEval: Benchmarking Chat Assistants on Long-Term Interactive Memory