What causes context pollution in a long-running agent?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Context pollution is when an agent's accumulated history of tool calls, observations, and thoughts crowds out the original task or the relevant signal, so the model loses focus or gets confused.
Imagine a tutor helping a student with one math problem. Every five minutes the tutor writes a fresh note: 'asked about fractions, then about decimals, then about negative numbers.' After two hours the notepad is full of side trips and the tutor can barely remember what problem they were originally solving. Context pollution is that notepad effect for an agent. Every tool call, every search result, every intermediate thought gets appended to the prompt. The original goal sits at the top buried under thousands of words of detours. When the model goes to take the next step, it spends most of its attention on the loudest noise nearby instead of the quiet original instruction.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
Define context pollution as growing history crowding out the original task or recent signal. Explain why it is a signal to noise problem, not a capacity problem. Describe two mechanisms: lost-in-the-middle attention skew and goal versus noise salience competition. Close with the four mitigation families and the working set versus log mindset.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Believing a larger context window solves it. Frontier models have a million-token context, yet attention degrades and signal to noise drops well before that limit. Pollution is a quality problem, not a capacity problem.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.