Glossary
Context poisoning
When incorrect or malicious content enters a language model’s input and is treated as true on later steps, compounding the error across a task or session.
Context poisoning is what happens when incorrect or malicious content enters a language model’s input and is then treated as true on every later step. The bad content might be the model’s own mistake, such as a hallucinated fact or a wrong intermediate conclusion, or it might arrive from outside, through a retrieved document, a tool result or a stored memory. Either way, the problem compounds: once the error is in the context, the model reasons from it, repeats it, builds plans on it and may write it back into memory, where it poisons future sessions too. Fixing it means removing or correcting the bad content at its source, since the model cannot reliably ignore something that sits in its own input.
How context poisoning happens
A language model has no separate channel for “things I know are true” and “things I read in the prompt”. Everything in the context window is evidence, and content that appears authoritative or is repeated several times carries more weight. That property is what makes in-context information useful, and it is also why a single wrong statement can steer a whole task.
In an agent, the input grows on every turn of the agent loop. Each step appends the model’s reasoning, its tool calls and their results. If step four contains a mistake, steps five to forty all see it. The model tends to stay consistent with what it has already said, so a wrong assumption early in a task is usually reinforced rather than questioned.
There are two broad routes in. The first is self-inflicted: the model produces a hallucination, misreads a tool output, or reaches a faulty conclusion, and that output becomes part of its own context. The second is external: content from a web page, a document, an email, a tool or another agent is wrong or deliberately crafted, and the agent ingests it without checking.
Self-inflicted poisoning
Long-running agents show this pattern most clearly. An agent working through a multi-hour task might misremember the state of its environment, record a goal that is impossible to reach, or decide that a tool is broken after one failed call. Each of those beliefs can persist in its notes or transcript and keep shaping its actions long after the original error. Reports from teams running agents on long tasks describe models pursuing objectives that no longer make sense because a mistaken belief was written into their working notes and never revisited.
Summaries make this worse in a specific way. When a conversation is compressed, a wrong statement can be preserved as a clean, confident sentence while the context that showed it was tentative is discarded. Context compression is useful, but a poisoned summary is harder to spot than a poisoned transcript.
Chain-of-thought reasoning has a similar effect. Written reasoning makes a model’s intermediate conclusions explicit, which helps accuracy on average, but it also means an early slip in the reasoning becomes a stated premise for what follows.
External poisoning
External poisoning comes in two forms. Accidental poisoning is the everyday case: an out-of-date help article, a document with a typo in a figure, a search result about a different product with a similar name. In retrieval-augmented generation, a chunk that is on the right topic but wrong for the question is enough to produce a confident wrong answer, and stale knowledge in an unmaintained corpus is a steady source of it.
Deliberate poisoning is an attack. Indirect prompt injection hides instructions in content the agent will read, such as a web page, a PDF or an email, hoping the model will follow them. Tool poisoning targets the descriptions and outputs of tools an agent connects to. Memory poisoning aims at persistent stores: if an attacker can get a false fact or instruction saved to an agent’s memory, it will be retrieved and trusted in later sessions, long after the original conversation is gone. These overlap with prompt injection but differ in emphasis. Injection is about instructions; poisoning is about anything false that the model goes on to believe.
Context poisoning and related failures
Poisoning is one of several ways context goes wrong, and the fixes differ, so it is worth telling them apart. A field guide to context failures covers the set in more depth.
Failure | What goes wrong | Typical cause | Main fix |
|---|---|---|---|
Context poisoning | False content is treated as true | Hallucination, bad source, attack | Remove or correct the content at its source |
Too much past content pulls attention from the task | Very long histories | Prune, offload or summarise | |
Accuracy falls as input grows | Input length itself | Keep inputs small and relevant | |
Stored facts go stale or conflict | Facts change over time | Contradiction resolution on write | |
Relevant content in mid-context is overlooked | Position in long input | Retrieve less, place key content at the edges |
The failures interact. A long, distracted context gives errors more room to hide, and a store with no handling for changing facts turns an ordinary update into a contradiction the model has to resolve on its own.
Why it is hard to undo
Telling the model “ignore what you said earlier” rarely works well. The wrong content stays in the input alongside the correction, and the model has to weigh two conflicting statements. Sometimes it picks the right one, sometimes it averages them, and sometimes it reverts to the original on a later step. The more often the poisoned claim has been repeated, the stronger its pull.
Persistent stores raise the stakes. A poisoned fact in a single conversation disappears when the session ends. A poisoned fact in long-term memory, a shared knowledge base or a multi-agent workspace can affect every future session and every agent that reads from it, which is why agent memory systems need a way to supersede, correct and delete what they hold.
Preventing and recovering from context poisoning
Validate before you store. Treat anything an agent writes to memory or a knowledge base as a claim to check, not a fact. Check tool outputs against schemas, require sources for factual statements, and keep a record of where each stored fact came from so it can be traced. Source attribution makes this practical.
Keep the working context lean. The less irrelevant material in the input, the fewer places an error can hide. Context pruning removes finished tool outputs and failed attempts, and context offloading parks large material in storage so it is only read when needed.
Restart from clean state. When an agent has gone wrong, starting a fresh context from a verified plan and a small set of trusted facts is often more reliable than correcting it mid-stream. This is one reason to keep plans and facts in structured storage rather than only in the transcript.
Separate trusted and untrusted content. Mark retrieved documents, web pages and tool outputs as data, keep instructions in the system prompt, and give the agent the least privilege it needs, so injected instructions have less to act on. Guardrails that check outputs before they are acted on add another layer.
Make changes recoverable. If a poisoned agent edits files or records, you need to see what it changed and roll it back. Snapshots and agent rollback turn a bad run into something you can inspect and reverse.
Watch for it. Agent tracing that records each step, tool call and retrieved item makes it possible to find where a wrong belief entered, rather than only seeing the wrong final answer.
A worked example
A support agent is asked about an enterprise customer’s data export limits. On its first search it retrieves an old help article stating a 10 GB limit, which was raised to 50 GB last quarter. The agent quotes 10 GB, then saves “Customer X has a 10 GB export limit” to memory. Two weeks later a different agent, handling a billing question, retrieves that memory and advises the customer to buy an add-on they do not need. The original error was a single stale document; the damage spread through memory to a second agent and a second conversation.
Three changes would have contained it. Keeping the help centre current would have stopped the stale article being retrieved. A memory system that resolves contradictions would have replaced the stored fact once the updated limit appeared. And recording the source of the memory would have let the team find and correct every place it had been used. The figures are illustrative, but the chain is typical of customer support agents.
Where Exabase fits
Exabase is the storage and retrieval layer under an agent, so it addresses poisoning where it persists: in memory, in documents and in what an agent changes. It does not inspect your prompts or block injection attacks, and your agent still needs its own validation and guardrails.
Exabase Memory runs on the M-1 engine, which extracts facts, preferences and events and resolves contradictions when new information arrives. If a user moves from Toronto to Berlin, the stored city is updated rather than duplicated, so an outdated fact does not sit alongside the current one. Every memory has creation and modification timestamps, individual memories can be updated or deleted through the API (PUT and DELETE on /v2/memories/{id}), and memories can be marked immutable when they should never be changed by consolidation. The retrieving memories guide covers search with recency bias, query expansion and reranking.
Deep Search returns the specific passage that matches a query, with page numbers and timestamps, which makes it easier to cite and check sources rather than pass whole documents into the prompt. Workers can keep a knowledge base current on a schedule, re-extracting changed documents and pruning content that has aged out, which reduces the supply of stale sources. Bases keep each tenant, user or agent in its own isolated environment, so a poisoned store in one cannot spread to another, and filesystem snapshots (off by default, enabled per Base) let you see what an agent renamed, moved or deleted over the last 7 days and recover deleted resources. The agent undo and agent memory solutions describe both patterns.
Frequently asked questions
What is the difference between context poisoning and prompt injection?
Prompt injection is an attack that smuggles instructions into a model’s input. Context poisoning is broader: any false content that the model goes on to treat as true, whether it came from an attack, a bad source or the model’s own mistake.
Can a model recover from context poisoning on its own?
Sometimes, but not reliably. The poisoned content stays in the input alongside any correction. Removing it, or restarting from a clean context with verified facts, is more dependable than asking the model to disregard it.
How does context poisoning affect agent memory?
It can make an error permanent. If a wrong fact is saved to memory, every later session that retrieves it inherits the error. Memory systems need contradiction handling, provenance and deletion to contain it.
Is context poisoning the same as hallucination?
No. A hallucination is one source of poisoning. Poisoning describes what happens next, when the hallucinated content stays in context and shapes later reasoning.
How do you detect context poisoning?
Trace each step of the agent, record where facts came from, and compare stored facts against trusted sources. Evaluation that checks faithfulness to sources catches some cases before they spread.
Does Exabase prevent context poisoning?
It helps contain it rather than prevent it. Exabase Memory resolves contradictions and supports updating and deleting memories, Bases isolate each tenant, and snapshots let you see and recover what an agent changed. Input validation and injection defences remain the agent’s job.
Related pages: context distraction, context rot, hallucination, memory poisoning, indirect prompt injection, contradiction resolution, context pruning, agent memory, a field guide to context failures, best agent memory platforms