esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

What Is Context Rot?

What context rot is, why a bigger context window does not cure it, and how to keep an AI agent's context lean, explained simply for your AI interview.

In short

Context rot is the drop in an AI model's accuracy and recall as its context window fills with more text. A bigger window does not fix it on its own, so teams keep what goes in small, relevant and cleaned up.

10 min readIntermediateCommon · estimateFacts checked 26 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

Context rot is what happens when an AI model's context window fills with more and more text. Anthropic's docs describe it as accuracy and recall degrading as the window grows. The drop comes on gradually, so it is easy to miss. A bigger window doesn't fix it on its own. In my agents I keep the window lean: clear old tool results, summarise long chats, keep notes outside the window, and test recall at real lengths.

What is context rot, in plain words?

A model reads its whole context window for each answer. That window holds your instructions, the chat so far, and every tool result the model has pulled in. Context rot is the slow loss of accuracy and recall as the window fills with more text. Anthropic's docs define it that way: accuracy and recall degrade as the window holds more text.

Picture a new hire on day one who is handed the full employee handbook, three years of emails and last quarter's reports, then asked about the leave rule. The rule is in there somewhere. The more they carry, the more likely they skim past the page that matters. A model with a full window is in the same spot. A support bot is the same: forty turns of tool results can sit ahead of the one refund rule it must follow.

Key words

Context window
The text a model can read in one go: instructions, chat and tool results.
Token
A small piece of text, often part of a word. Models count their window in tokens.
Recall
Getting a fact back when you ask for it. Tests hide one fact in a long text to check it.
Tool result
The text a tool sends back, such as a search hit or an account export.
Compaction
Replacing a long history with a short summary, then starting a fresh window.

Why does a fuller context give worse answers?

Each new token uses up part of what Anthropic calls an attention budget. Every token has to be weighed against the others, so the model's focus is spread thinner as the text gets longer. Models also see shorter texts more often than long ones in training, so they have less practice with very long inputs.

  • “Studies on needle-in-a-haystack style benchmarking have uncovered the concept of context rot: as the number of tokens in the context window increases, the model's ability to accurately recall information from that context decreases.”

    Anthropic

  • “Waiting for larger context windows might seem like an obvious tactic. But it's likely that for the foreseeable future, context windows of all sizes will be subject to context pollution and information relevance concerns”

    Anthropic

The decline is a slope. Anthropic calls it a performance gradient, so there is no token count where the model suddenly fails. Plan for the slope from the start.

Here is a made-up case. A mid-size bank runs a support assistant. After 40 turns in one long chat, its window holds 40 tool results, the full chat history and the current refund rule, now buried among them. It quotes the old 30-day refund window from an early page. Nothing crashed. The answer just went stale.

How context rot builds up

Context window, filling up

Old transaction exports

from the first 40 turns

Chat history

kept whole, every turn

Refund rule

one line, now buried

Model

reads it all, recalls less

Stale answer

the refund rule was missed

  1. 1The whole window goes to the model, refund rule included, among old results.
  2. 2The model recalls the wrong thing, so it answers from an old policy.
A made-up support agent's window fills with old transaction exports and chat history. The refund rule sits among them, so the model answers from the wrong policy. Nothing errors; the answer comes out wrong.

How do you keep context from rotting?

Don't wait for bigger windows. Anthropic's guidance is to find the smallest possible set of high-signal tokens that gives the outcome you want. Five habits do most of the work.

  1. 1

    Clear old tool results

    Once a tool's answer has been used, the raw output rarely needs to stay. Anthropic calls this tool result clearing, one of the lightest forms of compaction.

  2. 2

    Summarise long history

    Compaction takes a conversation near the limit, summarises it, and starts a fresh window with the summary. Keep the decisions and open bugs, drop the chatter. The cost: summarise too hard and subtle details vanish, so test the summary.

  3. 3

    Keep notes outside the window

    The agent writes key facts to a file or memory store and reads them back when needed. Anthropic calls this structured note-taking.

  4. 4

    Split heavy work across sub-agents

    Each sub-agent works in a clean window and sends back a short summary. The main agent keeps the plan and stays small.

  5. 5

    Load documents just in time

    Keep file paths and links, and load a document only when the step needs it, instead of pasting everything up front.

Keeping everything or curating

Keep everything

Every tool result

40 turns, all still in view

Curate

Clear and summarise

keep the rule and recent turns

Recall drops

the refund rule gets missed

Recall holds

the rule is still in view

  1. 1Every result stays, so the window keeps growing until the rule is buried.
  2. 2Old results are cleared and summarised, so the window stays small enough to recall from.
The same made-up support agent, run two ways. Keeping every result lets the window grow until the refund rule is buried. Clearing old results and summarising keeps the window small enough to recall from.

Here is a small sketch of the second way. It keeps the refund rule and the last three items, and drops the rest. The numbers are made up to show the effect.

Python
# A made-up support agent after 40 turns. Each turn keeps one tool result of 3,500 tokens.
TOKENS_PER_RESULT = 3500
TOKENS_PER_RULE = 40
RULE = "policy: refund requests close after 60 days"

def size(items):
    return sum(TOKENS_PER_RULE if x.startswith("policy:") else TOKENS_PER_RESULT for x in items)

turns = [f"turn {i}: transaction export" for i in range(1, 41)]
history = [RULE] + turns
print("Kept everything:", len(history), "items,", size(history), "tokens")

def curate(items, keep_last=3):
    rule = [x for x in items if x.startswith("policy:")]
    recent = [x for x in items if not x.startswith("policy:")][-keep_last:]
    return rule + recent

lean = curate(history)
print("After curation:", len(lean), "items,", size(lean), "tokens")
print("Rule kept:", RULE in lean)

Output

Kept everything: 41 items, 140040 tokens
After curation: 4 items, 10540 tokens
Rule kept: True

How would you spot context rot in a support bot?

Look for answers that quote old policy, a limit the customer stated twenty messages back that the bot forgets, and replies that get slower and costlier as chats run longer. Those are signs to check, so test before you blame the model.

Tip

Plant a known fact early in a long test chat, then ask for it at the end. Run the test at the lengths real customers reach.

What does the interviewer want to hear?

A strong answer covers

  • A plain definition: accuracy and recall fall as the window fills.
  • Why it happens: every token competes for the model's focus.
  • A bigger window does not cure it, so curation matters.
  • Fixes: clear old results, summarise, keep notes outside, split work.
  • How you would test recall at real conversation lengths.
  • It comes on gradually, so teams miss it without a test.

Common traps

  • Trap"A bigger context window fixes it."

    BetterA bigger window gives room, but recall still falls as text grows. Curate what goes in.

  • Trap"Paste all the docs in and the model will find it."

    BetterRecall falls with length. Load only the pages the step needs, then test recall at real lengths.

  • Trap"Context rot is an error that crashes the app."

    BetterNothing crashes. Answers just get worse, which is why teams miss it.

Can you spot the rot risk?

Spot the risk

Which line lets context rot set in for a support agent?

Quick check

A support agent quotes an old refund window more often as chats get longer. What is the most likely cause?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 5

What will they ask next?

  1. Q084What is "lost in the middle"?11 min
  2. Q096What is compaction (summarising history)?11 min
  3. Q097What is structured note-taking (external memory)?12 min
  4. Q138RAG vs long context: which to use?12 min
  5. Q008What is a context window?11 min
  6. Q082Context engineering vs prompt engineering?11 min

Learn it in depth

Last updated on 26 November 2026

Building an agent that has to stay accurate over long chats?

I design and build AI products and agents, including the UI and the system behind them. Book a short call and tell me how long your conversations run and what the agent must remember.