Agent Anti-Patterns · ~6 min
The first instinct when an agent fails is to give it more. More files, more history, more docs. That instinct is the anti-pattern.
The pattern is seductive because it sounds safe: load every potentially relevant file, the full conversation history, all the docs, complete tool results. More information can't hurt. It can, and it does.
A coding agent is asked to fix one failing test in a 200-file repo. The developer pre-loads the whole codebase
with @workspace, attaches 50 prior turns, and pastes three git log dumps — 180,000 tokens.
The agent finds the test, then rewrites an unrelated module it "noticed," ignores the
fix-only constraint from turn 1, and ships a 12-file diff. Roll back, retry with just the failing test and its two
imports in a fresh session, and it fixes the test in one turn.
Attention is finite even when the window is not. Anthropic's context-engineering guide names this context rot: recall and use of information degrade as token count grows. Irrelevant context is not inert — it adds noise that competes with signal for a fixed attention budget, and tokens in the middle of a long prompt receive the least attention of all (the lost-in-the-middle effect).
Anthropic's framing: find "the smallest possible set of high-signal tokens that maximize the likelihood of your desired outcome" — not the largest set you can fit. Volume is the wrong objective.
Replace volume with precision. Each lever trades a chunk of always-loaded context for on-demand access:
LangChain's Deep Agents applies these in sequence as pressure rises — offload large results, truncate older tool calls, summarise history — rather than all at once.
The remediation loses under specific conditions: unreliable retrieval (poor recall beats RAG with high miss rates), a tight latency budget (on-demand adds round-trips), truly homogeneous context (a whole-repo rename has nothing irrelevant to exclude), and short tasks where sub-agent orchestration overhead isn't worth it.
Retrieval practice — recall, don't peek
Question 1A larger context window, on its own, tends to…
Question 2Anthropic's stated goal for context is the…
Question 3The most common cause of this anti-pattern is…
Question 4Loading more context can be the right call when…
Question 5Tokens in the middle of a long prompt are…