Context Poisoning, Distraction, Confusion, Clash and Rot
When an agent behaves strangely, look first at what it was shown.
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.
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.
| Failure | Plain meaning | Everyday example | First repair |
|---|---|---|---|
| Poisoning | Something false is treated as fact | A wrong order number is copied into the plan | Remove it and rebuild from trusted data |
| Distraction | Too much material crowds out the task | The agent repeats past actions in a very long run | Trim and summarize |
| Confusion | Irrelevant or unclear material misleads | It picks the wrong one of two similar tools | Offer only what is relevant |
| Clash | Items contradict each other | Two policy versions give different limits | Decide which source wins |
| Rot | Reliability declines with age or length | A cached price from last month is used | Refresh, expire, restart |
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
- Stop further actions that depend on the item.
- Find where it first appeared.
- Rebuild the context from the last trusted state. Adding "that was wrong" leaves the false text in view and may not be enough.
- Purge it from summaries, memory and caches.
- 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.
| Ambiguity | Fix |
|---|---|
| Two similar tools | Merge them, or state when to use each |
| Many irrelevant tools | Load a task-specific set |
| "The customer" when two appear | Use names and IDs; separate records clearly |
| Example data that looks real | Label examples, and use obviously fictional values |
| Unrelated documents from broad search | Filter 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.
| Turn | What happens | Failure at work |
|---|---|---|
| 3 | The agent infers the size from an old order and writes "size M" into its plan | An assumption enters as fact: poisoning begins |
| 9 | A supplier search returns long catalog pages | Bulk begins to distract |
| 14 | Two price lists appear, one from last year | Clash, with a stale source |
| 18 | A summary compresses history to "user wants size M gloves" | The guess now looks like a user statement |
| 22 | The agent prepares an order using last year's price | Both 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.
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.
| Between | Rule to apply |
|---|---|
| Instructions of different authority | Higher authority wins; retrieved text has none |
| Two facts from different systems | Name a system of record for each kind of fact |
| Two versions of a document | Use the one in force on the relevant date; filter the other out |
| Two equally credible sources | Show both, say they disagree and ask or escalate |
| Old user preference and new statement | Newer explicit statement wins; update memory |
Context rot: notice stale or degraded context
Two different things go under this name, and they need different fixes.
| Aspect | Length-related decline | Staleness |
|---|---|---|
| Cause | Input grows long or full of look-alike material | Facts changed after they were captured |
| Sign | Success falls as runs get longer | Confident use of outdated values |
| Detect | Plot success against input size and turn number | Compare timestamps with a maximum age |
| Fix | Compact, restart from notes, isolate | Expire, 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.
Debug: the agent used stale or irrelevant context
| Finding | Likely stage to fix |
|---|---|
| Old document ranked above new | Indexing and metadata filters |
| Deleted document still retrieved | Index update or cache invalidation |
| Value changed during the run | Re-read immediately before the action |
| Summary lost a "not" | Compression rules and checks |
| Memory from another user | Isolation. Treat as a security incident |
| Right fact present but ignored | Order, noise, wording or model choice |
Controls mapped to failures
| Control | Poisoning | Distraction | Confusion | Clash | Rot |
|---|---|---|---|---|---|
| Source and date on every item | Yes | Yes | Yes | ||
| Verify before acting | Yes | Yes | |||
| Task-specific tool sets | Yes | Yes | |||
| Short tool results | Yes | Yes | Yes | ||
| Authority and conflict rules | Yes | Yes | |||
| Sub-agents with separate context | Limits spread | Yes | Yes | ||
| Fresh context from notes | If notes are checked | Yes | Yes |
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 observe | Check first |
|---|---|
| The same wrong value everywhere | Where it first appeared: poisoning |
| Good early, worse late in a run | Input size and history: distraction or length rot |
| Wrong tool or wrong record chosen | Overlap and labels: confusion |
| Answers flip between runs | Conflicting items: clash |
| Yesterday's answer to today's question | Timestamps 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.
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
- How contexts fail and how to fix them (Drew Breunig)
- Context Rot: How Increasing Input Tokens Impacts LLM Performance (Chroma)
- Lost in the Middle (paper)
- Effective context engineering for AI agents (Anthropic engineering)
Next steps
Context Isolation, Provenance and Governance
Keep contexts separate and traceable.
Memory Integrity, Isolation and Sharing
Protect long-term memory from bad writes.
Debugging Agents, RAG and Handoffs
A wider method for finding causes.