Context Poisoning
An early hallucination or error repeatedly re-referenced in later turns.
A family recipe card says "1 tbsp salt" where the grandmother meant a teaspoon. Someone copies the card, the copy gets photocopied, and twenty years later the whole family believes the dish is supposed to taste that salty. Every copy was faithful. The error was in the source, and the faithfulness spread it.
Context poisoning works the same way. One wrong thing enters the context early: a misread value, a hallucinated function name, a wrong conclusion. Later turns cite it, build on it and repeat it. The agent's own earlier statements sit in the window with the same standing as tool output, so each repetition makes the falsehood look more established. Soon the plan is built around it, and new evidence against it gets explained away instead of believed.
In practice
A coding agent is adding partial refunds to a billing service. Watch the false fact survive a direct contradiction.
- T1
read_file("vendor/payments_sdk/refunds.py")→ 140 linesThe SDK provides refunds.partial(id, amount).There is no such method. The file definesrefunds.create(id, amount=None). The misreading now lives in the agent's own words. - T2
edit_file("billing/handler.py", ...)→ okWired up refunds.partial.The poison has spread from the context into the code. - T3
run_tests("billing")→ AttributeError: 'Refunds' object has no attribute 'partial'Our SDK must be outdated. Upgrade it to get partial().The error contradicts the false fact, and the agent invents a story that keeps it alive. - T4
run("pip install -U payments-sdk")→ upgraded 4.2 to 5.0A real dependency upgrade, with its own risks, now rests on a method that never existed.
Turn 3 is the telling moment. The environment said exactly what was wrong, and the poisoned context outvoted it.
Why it matters
Poisoned sessions don't heal well on their own. The longer the false fact stays, the more turns cite it, and the more evidence it takes to dislodge. The cost includes every turn after the bad one, plus the cleanup: reverted code, an unneeded upgrade and a reviewer who now has to read the whole trace to see where it went wrong. Often the cheapest repair is to restart from a clean state that explicitly records the fact as false.
What to do about it
H-11 Errors as Steering Prompts gives the agent evidence strong enough to win: an error that lists the methods that do exist (available: create, get, list) is much harder to explain away. H-10 Poka-Yoke Boundaries catches wrong names at the call boundary, before they become code. H-14 Memory Metabolism makes compaction keep a list of ruled-out facts, so the poison doesn't survive a summary.
Related
Token gravityLexicon · 16Token GravityBulky or salient tokens warping subsequent next-token probabilities toward themselves. is the force that keeps pulling the agent back to the false fact. Context clashLexicon · 24Context ClashContradictory observations from different turns colliding in the window. is a contradiction in plain view, while poisoning is a falsehood that goes unchallenged or wins when challenged. Context distractionLexicon · 22Context DistractionAccumulated history drowning out the core objective and instructions. can happen with every fact in the window true, because the goal gets buried by volume. Context confusionLexicon · 23Context ConfusionIrrelevant schemas or documents misleading the agent's tool selection. comes from material that is true but irrelevant, which leads the agent to the wrong tool.