Context Engineering in a Minute · intermediate

Context in a Minute: Context pollution

Context pollution is when irrelevant files, logs, or tool output crowd the model’s window and degrade the next decision.

Last verified: 2026-09-06

In one sentence

Context pollution is noise in the agent’s working memory that crowds out the facts needed for the current step.

Why it matters

Coding agents fail not only from weak models, but from cluttered context: huge logs, unrelated files, repeated failed attempts, and tool dumps. The model then reasons over the wrong evidence.

How it works

Pollution accumulates when sessions:

  • read entire directories “just in case”;
  • paste full CI logs instead of the failing assertion;
  • keep retrying without summarizing what changed;
  • attach too many MCP tool results.

Countermeasures:

  • start tasks with a short plan and file list;
  • prefer targeted reads;
  • summarize failures before continuing;
  • start a fresh session when the thread is contaminated.

Example

Instead of pasting 2,000 lines of test output, give:

npm test fails in contact-sheet.test.ts
Expected status 400, received 200 for empty email
Do not refactor unrelated form fields

Agentic coding use

Context engineering is an operations skill. The best agent teams treat context like a scarce working set: load what is needed, evict what is not.

Watch out

“Add more context” is not always the fix. Often you need less context and a clearer verification target.

Sources