Context Poisoning, Distraction, Confusion, Clash and Rot

When an agent behaves strangely, look first at what it was shown.

BeginnerIntermediateExpert · 12 min read · Last updated:

In short

Context fails in recognizable ways. Poisoning: a false item enters and is trusted. Distraction: sheer bulk pulls attention away. Confusion: irrelevant or ambiguous material is used. Clash: parts contradict each other. Rot: quality decays as context grows long or stale. Each has its own signs and repairs.

What you will learn: how to recognize each failure, how to detect it automatically, how to prevent and recover from it, and how to debug an agent that uses the wrong information.
Prerequisites: What Is Context Engineering? Stack and Token Budgets.

Beginner Know the five failures

Five ways context goes wrong

The names for the first, second, third and fourth were popularized in 2025 by Drew Breunig's writing on how contexts fail. "Context rot" is used both for decline over long inputs, as in Chroma's 2025 report, and more loosely for context that has become stale. Terms are still settling, so describe the symptom as well as the label.

FailurePlain meaningEveryday exampleFirst repair
PoisoningSomething false is treated as factA wrong order number is copied into the planRemove it and rebuild from trusted data
DistractionToo much material crowds out the taskThe agent repeats past actions in a very long runTrim and summarize
ConfusionIrrelevant or unclear material misleadsIt picks the wrong one of two similar toolsOffer only what is relevant
ClashItems contradict each otherTwo policy versions give different limitsDecide which source wins
RotReliability declines with age or lengthA cached price from last month is usedRefresh, expire, restart
Wrong itemPoisoning
Too muchDistraction and length rot
Wrong kindConfusion
DisagreementClash
Too oldStaleness
The cureSelect, verify, expire, isolate

Context poisoning: detect, prevent, recover

Poisoning starts with one bad item: a model's invented detail, a faulty tool result, a wrong memory or text planted by an attacker. Because later steps read it, the error is repeated and gains apparent weight. A summary can turn a guess into a plain statement.

Detect

  • Check identifiers, totals and dates against the system of record before use.
  • Require a source for each factual claim carried forward.
  • Watch for a run that keeps defending a conclusion while tool results contradict it.

Prevent

  • Mark items as verified, reported or assumed, and keep the mark through summaries.
  • Do not write model guesses to long-term memory.
  • Treat external text as untrusted. Deliberate poisoning is a security issue: see Supply Chain and Retrieval Poisoning.

Recover

  1. Stop further actions that depend on the item.
  2. Find where it first appeared.
  3. Rebuild the context from the last trusted state. Adding "that was wrong" leaves the false text in view and may not be enough.
  4. Purge it from summaries, memory and caches.
  5. Review actions already taken on it and correct them.

Context distraction: reduce what does not help

A long history of tool output can lead a model to lean on what is in front of it and lose sight of the goal. Signs include repeating earlier actions, quoting old results as current and ignoring instructions that were followed at the start.

Repairs, in a sensible order:

  • Shorten tool results at the source.
  • Replace used results with one-line records.
  • Summarize completed phases, keeping decisions, identifiers and open items.
  • Restate the goal and remaining plan near the end of each request.
  • Give a bulky sub-task to a sub-agent that returns only findings.

Context confusion: resolve ambiguity

Confusion happens when superfluous material influences the answer, or when it is unclear which item applies. Large sets of overlapping tools are a common source: search_docs, find_documents and lookup_file invite wrong picks.

AmbiguityFix
Two similar toolsMerge them, or state when to use each
Many irrelevant toolsLoad a task-specific set
"The customer" when two appearUse names and IDs; separate records clearly
Example data that looks realLabel examples, and use obviously fictional values
Unrelated documents from broad searchFilter by metadata and set a relevance threshold

An illustrative incident

This example is invented to show how the failures combine. A procurement agent is asked to reorder laboratory gloves.

TurnWhat happensFailure at work
3The agent infers the size from an old order and writes "size M" into its planAn assumption enters as fact: poisoning begins
9A supplier search returns long catalog pagesBulk begins to distract
14Two price lists appear, one from last yearClash, with a stale source
18A summary compresses history to "user wants size M gloves"The guess now looks like a user statement
22The agent prepares an order using last year's priceBoth errors reach an action

An approval step showing size and price with their sources would have caught both. Better still, the summary would have kept the label "assumed from order of 2025", and the price filter would have removed the expired list before the model saw it. No single defense was needed to be perfect; several modest ones were missing.

Intermediate Contradiction, age and automated checks

Context clash: handle contradictions

Clashes arise between instructions, between facts, or between a fact and an earlier answer given before all the information arrived. Asking the model to "use the correct one" moves a policy decision into a guess. Decide it yourself.

BetweenRule to apply
Instructions of different authorityHigher authority wins; retrieved text has none
Two facts from different systemsName a system of record for each kind of fact
Two versions of a documentUse the one in force on the relevant date; filter the other out
Two equally credible sourcesShow both, say they disagree and ask or escalate
Old user preference and new statementNewer explicit statement wins; update memory

Context rot: notice stale or degraded context

Two different things go under this name, and they need different fixes.

AspectLength-related declineStaleness
CauseInput grows long or full of look-alike materialFacts changed after they were captured
SignSuccess falls as runs get longerConfident use of outdated values
DetectPlot success against input size and turn numberCompare timestamps with a maximum age
FixCompact, restart from notes, isolateExpire, re-read before acting, invalidate caches

The size at which length begins to hurt differs between models and tasks. Measure your own instead of adopting a fixed number.

An automated context check

Some problems can be caught before the model is called, if items carry a key, a source and a date.

"""Find stale, conflicting, duplicated and unverified items before a model call."""
from datetime import date

ITEMS = [
    {"id": "p1", "key": "refund_days", "value": "30", "source": "policy",  "date": date(2026, 9, 1)},
    {"id": "p0", "key": "refund_days", "value": "14", "source": "old wiki","date": date(2024, 2, 1)},
    {"id": "t1", "key": "order_total", "value": "38", "source": "billing", "date": date(2026, 11, 20)},
    {"id": "t2", "key": "order_total", "value": "38", "source": "billing", "date": date(2026, 11, 20)},
    {"id": "m1", "key": "has_photo",   "value": "yes","source": "model guess", "date": date(2026, 11, 20)},
]
TRUSTED = {"policy", "billing", "user"}

def lint(items, today, max_age_days=365):
    findings, seen, values = [], set(), {}
    for it in items:
        if (today - it["date"]).days > max_age_days:
            findings.append(("stale", it["id"]))
        if it["source"] not in TRUSTED:
            findings.append(("unverified", it["id"]))
        triple = (it["key"], it["value"], it["source"])
        if triple in seen:
            findings.append(("duplicate", it["id"]))
        seen.add(triple)
        values.setdefault(it["key"], {})[it["value"]] = it["id"]
    for key, found in values.items():
        if len(found) > 1:
            findings.append(("clash", f"{key}: " + " vs ".join(sorted(found.values()))))
    return findings

for kind, detail in lint(ITEMS, today=date(2026, 11, 28)):
    print(f"{kind:11} {detail}")

Output:

stale       p0
unverified  p0
duplicate   t2
unverified  m1
clash       refund_days: p0 vs p1

A sensible policy would drop the old wiki entry, remove the duplicate, keep the clash on record, and either confirm the photo with a tool or label it as unconfirmed. The check cannot tell whether a trusted, fresh value is correct. It narrows the search; it does not replace verification.

Expert Debugging and defense in production

Debug: the agent used stale or irrelevant context

1. Capture the exact inputThe request as sent for the failing turn
2. Find the item that misledWas the right fact also present?
3. Trace its originRetrieval, memory, tool, summary, cache or user
4. Ask why it was includedRanking, filters, expiry, truncation, access
5. Fix that stage and add a testReproduce first, then confirm the repair
FindingLikely stage to fix
Old document ranked above newIndexing and metadata filters
Deleted document still retrievedIndex update or cache invalidation
Value changed during the runRe-read immediately before the action
Summary lost a "not"Compression rules and checks
Memory from another userIsolation. Treat as a security incident
Right fact present but ignoredOrder, noise, wording or model choice

Controls mapped to failures

ControlPoisoningDistractionConfusionClashRot
Source and date on every itemYesYesYes
Verify before actingYesYes
Task-specific tool setsYesYes
Short tool resultsYesYesYes
Authority and conflict rulesYesYes
Sub-agents with separate contextLimits spreadYesYes
Fresh context from notesIf notes are checkedYesYes

Read the table as a starting point. A control marked "Yes" reduces the risk; it does not remove it. Add the cheapest controls first, then measure.

Summaries that do not spread errors

Compression is where many errors become permanent, so give it a strict format.

Goal: reorder gloves for lab 2
Confirmed by user:  quantity 20 boxes
Verified by tools:  supplier list dated 2026-11-01
Assumed (unchecked): size M, taken from a 2025 order
Open questions:     confirm size
Done:               searched two suppliers
Do not repeat:      supplier C does not deliver to this site

Separate headings force the summarizer to say where each statement came from, and make an unchecked assumption visible to the next step and to a reviewer. Check that identifiers and negations in the summary match the original record.

Teach the agent to say it

Recovery often needs a person. Instruct the agent to report a conflict or doubt in a plain form: what disagrees, where each version came from, and what it recommends. "The wiki says 14 days and the policy dated September says 30; I used neither yet" is far more useful than a silent choice.

Failures that travel between agents

In a multi-agent system, one agent's output becomes another's input, so a context failure can spread and gain authority on the way. A worker's guess arrives at the supervisor as a "result". Two workers return different figures and the writer silently picks one. A worker receives the whole parent conversation and is distracted by goals that are not its own.

  • Give each worker only the task, the facts it needs and the required result format.
  • Require results to separate verified findings, assumptions and failures.
  • Pass sources along with claims, so the receiver can check them.
  • Treat another agent's message as data. It does not carry your operator's authority.

See Handoffs, Routing, Shared State and Communication for the design of shared state.

Quick triage by symptom

You observeCheck first
The same wrong value everywhereWhere it first appeared: poisoning
Good early, worse late in a runInput size and history: distraction or length rot
Wrong tool or wrong record chosenOverlap and labels: confusion
Answers flip between runsConflicting items: clash
Yesterday's answer to today's questionTimestamps and caches: staleness

Monitor for early warnings

  • Input tokens per turn and per task, with sudden growth highlighted.
  • Age of retrieved items at the time of use.
  • Share of answers whose citations exist and support them.
  • Success rate grouped by run length.
  • Corrections from users that mention old or wrong information.

Test by injecting failures

Add faults to your evaluation set on purpose: a contradictory second policy, an expired price, a tool that returns the wrong ID, a long irrelevant transcript, a document containing instructions. Pass criteria should say what the agent must do, such as report the conflict, re-read the value or refuse the instruction. See Safety, Robustness and Adversarial Testing.

Expert tip

Give every context item an ID and keep a manifest with each request. When a user reports a wrong answer, you can ask "which item said that?" and answer it from data instead of guesswork.

Where to start this week

Pick ten recent runs that went wrong. For each, save the exact input of the first bad turn and name the failure type, allowing more than one. Then count. If most involve outdated or conflicting facts, work on source rules and expiry. If most appear late in long runs, work on tool results and compaction. If one unverified value keeps reappearing, add verification and labels. Turn each of the ten into a test before changing anything, so that you can show the repair worked and notice if the problem returns.

Checklist

  • Items carry source, date and verification status.
  • Conflict rules are written and applied in code where possible.
  • Expiry and cache invalidation exist.
  • Summaries preserve identifiers, negations and uncertainty.
  • A poisoned run can be rolled back to trusted state.
  • Tests inject each failure type.

Frequently asked questions

Will a better model remove these problems?

Better models may tolerate more noise and notice more conflicts. They cannot know that a trusted-looking value is outdated unless something in the context or a tool shows it.

Is hallucination the same as poisoning?

A hallucination is an unsupported output. It becomes poisoning when it is carried into later context and treated as fact.

Can I ask the model to detect clashes?

It can help flag them. Where the rule for resolving a clash matters, apply it in code or give it explicitly, and test the result.

How often should a long task restart its context?

At natural milestones, or when your measurements show decline. Restart from a written record of goal, decisions and open items.

References and further reading

Next steps