Blog5 min read

Context Pollution: When More Context Makes AI Agents Worse

Context pollution happens when irrelevant, stale, duplicated, or conflicting information competes with the instructions and evidence an AI agent needs for its current task.

By Ntense

More context often helps at first. A model needs the task, the local meaning, the constraints, and the evidence it cannot infer. Beyond that point, additional material can compete with what matters.

A context window is not a perfectly indexed database. It is the model's working material for one inference. Every repeated transcript, stale rule, giant tool response, and marginally relevant document consumes attention as well as tokens.

Anthropic describes context as a finite resource and defines context engineering as curating the information available to an agent at inference time. Its practical target is the smallest set of high-signal tokens that maximises the chance of the desired behaviour.[1]

A clear luminous information path crosses a field of duplicated paper fragments and translucent clutter
A larger context window provides capacity; relevance determines whether that capacity helps.

Why context pollution is especially dangerous for agents

A chatbot may answer once and stop. An agent loops: it plans, calls tools, reads results, edits files, receives errors, and continues. Its context can grow at every step. Yesterday's hypothesis, a failed tool trace, and an obsolete instruction may remain beside the current task unless the system actively compacts, updates, or discards them.

The result is rarely a dramatic crash. More often the agent follows a lower-priority rule, repeats work, misses a local constraint, treats an old result as current, or spends time reconciling information that should never have been loaded together.

A large AGENTS.md can become part of the problem

Repository instructions are valuable because they preserve local knowledge. They become harmful when one top-level file attempts to contain every feature detail, historical decision, troubleshooting note, and example. The task and relevant code then compete with a manual the agent did not need.

OpenAI's February 2026 account of an agent-first software project says its short AGENTS.md acts as a table of contents while structured repository documentation remains the system of record. The lesson is architectural: give the agent a map, then let it load the detail required for the current task.[2]

The top-level agent file should orient the work. Scoped files and source-of-truth documents should carry the depth.

Context-window size is not context quality

A model that accepts a long input does not necessarily use every part equally well. Capacity removes one limit—the number of tokens accepted—but it does not guarantee perfect retrieval, prioritisation, or reasoning across those tokens.

The peer-reviewed 2024 “Lost in the Middle” study tested multi-document question answering and key-value retrieval. Performance often peaked when relevant information appeared near the beginning or end and declined when it was buried in the middle. The result is task- and model-specific, but it shows why placement and curation matter.[3]

A 2025 EMNLP paper tested five open- and closed-source models on maths, question answering, and coding. It found performance degradation as inputs grew even when retrieval was controlled, with results varying substantially by model and task. This does not mean long context is always bad; it means a large window is capacity, not a target to fill.[4]

Context starvation and context pollution are opposite failures

Context starvation

The model lacks information it cannot safely infer: the customer's goal, a local business rule, the relevant schema, a current error, a security boundary, or the definition of done. The answer may sound plausible while being wrong for this system.

Context pollution

The necessary facts are present, but they are surrounded by stale conversation, duplicate documentation, huge raw tool output, every memory ever stored, or rules for unrelated work. The model spends its attention budget separating signal from noise.

Where context pollution comes from

  • Conversation history: old plans and superseded assumptions remain active.
  • Retrieval: too many loosely related chunks are added because recall is valued without a precision check.
  • Tool results: logs, HTML, traces, or database rows are injected in full instead of filtered to the decision.
  • Memory: the system remembers everything but has no rule for relevance, expiry, conflict, or user control.
  • System instructions: each failure adds another rule, but obsolete rules are never consolidated or removed.
  • Repository files: global guidance contains detail that belongs beside one feature or domain.

Use progressive disclosure instead

Progressive disclosure keeps a small orientation layer active and makes deeper information available through stable references. The agent begins with the goal, non-negotiable boundaries, and a map of sources. It reads the relevant source only when the task reaches that area.

  1. Keep the global instruction file short: identity, safety, repository map, and universal commands.
  2. Put feature rules near the feature and data rules near the canonical data.
  3. Retrieve a small number of highly relevant chunks, then expand only when evidence is missing.
  4. Summarise long tool results into decisions, evidence, unresolved questions, and stable references.
  5. Expire or supersede memory explicitly; do not let old facts compete silently with new ones.

A seven-question context audit

  • Can the agent identify the current goal in one sentence?
  • Which facts are unique to this project or user and therefore deserve priority?
  • Which instructions, memories, or results may be stale or superseded?
  • Is the same rule repeated in multiple places with slightly different wording?
  • Can raw tool output be filtered to the evidence required for the next decision?
  • Can low-frequency detail remain discoverable by path, link, or query instead of preloaded?
  • What test would reveal whether the revised context actually improves the outcome?

The better rule for AI context

Do not maximise prompt length. Maximise decision-relevant signal. Give AI the whole problem, but distinguish the whole problem from the whole organisation. A strong context says what outcome matters, what must not happen, what evidence is current, and where the agent can find more when it needs it.

Sources

  1. Effective context engineering for AI agents — Anthropic Accessed Thu Aug 13 2026 00:00:00 GMT+0000 (Coordinated Universal Time). Defines context engineering, treats context as a finite attention budget, recommends the smallest high-signal set of tokens, and describes just-in-time retrieval, compaction, note-taking, and multi-agent separation.
  2. Harness engineering: leveraging Codex in an agent-first world — OpenAI Accessed Thu Aug 13 2026 00:00:00 GMT+0000 (Coordinated Universal Time). Describes an agent-first repository where a short AGENTS.md acts as a table of contents and structured repository documentation is the system of record.
  3. Lost in the Middle: How Language Models Use Long Contexts — Transactions of the Association for Computational Linguistics Accessed Thu Aug 13 2026 00:00:00 GMT+0000 (Coordinated Universal Time). Reports multi-document question-answering and key-value-retrieval experiments in which model performance often fell when relevant information appeared in the middle of a long context rather than near its beginning or end.
  4. Context Length Alone Hurts LLM Performance Despite Perfect Retrieval — Association for Computational Linguistics Accessed Thu Aug 13 2026 00:00:00 GMT+0000 (Coordinated Universal Time). Reports experiments across five models and maths, question-answering, and coding tasks where performance degraded as input length increased even under controlled retrieval conditions; effects varied by model and task.