How context goes wrong
8 min read
Not every wrong answer is the model's fault
When an assistant gets something wrong, people often say it hallucinated. That is sometimes true. A AI hallucinationAn answer that sounds confident but is false. The model wrote text that fits the pattern instead of text that is true. is a false statement that appears nowhere in the model's input, and the Lesson Why models make things up explains it. But in applications with documents and tools, many wrong answers are faithful to a bad context. The model read what it was given, and what it was given was wrong, stale, crowded or contradictory.
The distinction matters because the fixes differ. You do not cure a stale policy by changing the model or the temperature. You cure it by changing what goes in. This Lesson names four faults so that you can tell them apart. The four names come from the article How Contexts Fail and How to Fix Them.
| What happens | Typical cause | The fix | |
|---|---|---|---|
| Poisoning | A wrong fact enters and is built upon | A tool error or an earlier mistake saved to the history | Validate before saving, and drop the bad entry |
| Distraction | The model leans on the pile, not the task | A long history or too many documents | Trim, summarise and send less |
| Confusion | Irrelevant material is treated as relevant | Many tools or loosely matched passages | Select harder, and give fewer tools |
| Clash | Two sources disagree | An old and a new version of one rule | Remove or date the old one |
Poisoning
A wrong statement that enters the context tends to stay. The model reads it at every later step and may build on it. Suppose a tool returns the wrong order date and the agent writes it into its notes. Every later answer now rests on that date, and the model sounds sure of it. The fix is early: check what you save, and keep a way to remove an entry.
Distraction
A long context can pull the model toward what is in front of it and away from the task. A very long history is the classic case. The model repeats earlier actions, or answers an old question. Chroma tested 18 models and found that performance becomes less reliable as the input grows, even on simple tasks. Its report, Context Rot, gave the trend its name. Context rotThe drop in reliability that appears as the input to a model grows longer, even on simple tasks. Sending less text is the main fix. is a size problem, so the cure is less text, as the Lessons Context is a budget and History and summaries describe.
Confusion
Irrelevant material is not always ignored. A passage that is only loosely related to the question can be used anyway, and a long list of tools can lead the model to choose the wrong one. Send fewer, better pieces, and give an agent only the tools that the current task needs. Choosing useful context shows a selection step that logs its reasons.
Clash
Two parts of the context can disagree. The common case is an old and a new version of the same rule, such as returns in 14 days and returns in 30 days. The model cannot know which is current, so it picks one, or blends them, or hedges.
A clash is the easiest of the four to detect with code, because you can compare facts across sources. The program below holds four passages. It finds the number of days stated for each topic, and reports any topic that has more than one value.
import re
passages = [
{"topic": "returns", "year": 2023, "text": "Unused bikes can be returned within 14 days."},
{"topic": "returns", "year": 2026, "text": "Unused bikes can be returned within 30 days."},
{"topic": "warranty", "year": 2025, "text": "The frame has a warranty of 5 years."},
{"topic": "shipping", "year": 2026, "text": "Standard shipping takes 5 days."},
]
by_topic = {}
for passage in passages:
number = int(re.search(r"\d+", passage["text"]).group())
by_topic.setdefault(passage["topic"], []).append((passage["year"], number))
for topic, values in by_topic.items():
numbers = {number for _, number in values}
if len(numbers) > 1:
newest = max(values)
print(f"clash in {topic}: {sorted(numbers)}; newest is {newest[1]} from {newest[0]}")
else:
print(f"ok: {topic}")It prints:
clash in returns: [14, 30]; newest is 30 from 2026
ok: warranty
ok: shippingThe returns topic has two values, 14 and 30, and the check names the newer one. A real check would be more careful than reading the first number, but the idea scales. Compare the figures, dates and names across the sources you are about to send, and stop on a disagreement.
A report is only the start. Decide the rule in advance: drop the older passage, send only the newest, or send both with their dates and tell the model to prefer the later one. Prefer removing the old text at the source, so the index stays clean.
Find the fault before you fix it
When a wrong answer comes in, read the exact context that was sent. Ask four questions in order.
- Is a wrong fact in it? That is poisoning.
- Is it very long, or full of text that has nothing to do with the question? That is distraction.
- Is related but unhelpful material in it? That is confusion.
- Do two parts of it disagree? That is a clash.
If the right fact is simply absent, the fault is neither of these: the context is incomplete, and the fix is retrieval, as in Why RAG systems fail. Log the full context for every request, so you can look at it afterwards.
Which fault is it when two sources give different return periods?
One passage says 14 days and another says 30.
A clash is two parts of the context that disagree. Remove or date the old one.
What is the first fix for a very long, crowded context?
Answers get less reliable as the history grows.
Distraction and context rot are size problems, so the cure is a smaller, better chosen context.
What do you do when the right fact is simply missing?
The context holds no wrong or conflicting text.
A missing fact is a retrieval problem, not one of the four faults.
Your reading position is saved
0 of 11 complete
Lesson complete
How context goes wrong
Up next