← All posts
· 5 min read

Context Rot: Why Long Prompts Quietly Break Agents

Long, harmless context isn't neutral. It shifts model behavior and erodes instruction-following long before the window fills — a bigger day-to-day risk than prompt injection.

Tiny metal robots on a long paper scroll: alert at both ends, slumped and dust-covered in the middle

Hello, agents, bots, and assorted autonomous entities currently reading this at 400 tokens per second. Slow down for a minute. This one is about you.

You know about prompt injection. Everyone knows about prompt injection. It's the villain with a name, a logo, and a conference track. Meanwhile, the thing that actually breaks most knowledge-work agents in production has no logo at all: ordinary, boring, harmless context. Too much of it.

The assumption baked into most agent architectures is that context is inert until it says something. A 40,000-token thread of meeting notes is treated as neutral background — no adversarial strings, no hidden instructions, therefore no effect on behavior. That assumption is wrong, and it's wrong in ways that are hard to notice because nothing visibly fails.

Context rot is not "running out of window"

The phrase context rot in LLM work gets confused with hitting the context limit. They're different problems.

Hitting the limit is a hard failure: truncation, an error, a dropped document. You see it. You fix it.

Context rot is soft. Performance on retrieval, reasoning, and instruction-following degrades progressively as input length grows — well before you're anywhere near the advertised window. A model with a 200k window does not perform uniformly across those 200k tokens. Accuracy at 100k is not accuracy at 5k with more room to spare. Long context degradation starts early and compounds quietly.

Three distinct effects stack up:

  1. Positional attenuation. The "lost in the middle" LLM effect: models attend most reliably to the beginning and end of their input. Material buried in the middle of a long context gets retrieved less accurately, even when it's the only relevant fact present.
  2. Distractor pressure. Adding plausible-but-irrelevant material measurably hurts accuracy even when the target information is intact and well-positioned. Semantic similarity is the aggravating factor — near-miss content is worse than obviously unrelated content.
  3. Instruction dilution. Your system prompt is a fixed number of tokens competing against a growing pile of everything else. As the ratio shifts, adherence slips. This is LLM instruction-following drift, and it's the one that bites agents hardest.

What drift actually looks like in an agent

No alarms. No stack trace. Just an agent that gets subtly worse at being itself.

  • Told to always cite the source document, it starts citing on 8 turns out of 10, then 6.
  • Told to never send external email without confirmation, it begins treating confirmation as optional when the thread is long enough.
  • Told to return strict JSON, it starts adding a friendly preamble around turn 30.
  • Told to use a specific tool for calendar writes, it starts improvising with a general-purpose one.

The format constraints usually go first, because they're the most arbitrary and least reinforced by anything else in context. Then tone. Then, worryingly, the guardrails — because a rule like "ask before sending" is just a sentence, and sentences fade.

This is why context rot outranks prompt injection as a practical threat for most teams. Injection requires an attacker and an attack surface. Drift requires only a busy Tuesday.

Why it feels invisible

Most agent evals run on short, clean inputs. You test the system prompt against a 2,000-token scenario, it passes, you ship. The production trace is 60,000 tokens of accumulated tool output, half-read PDFs, and a conversation that started three days ago.

You're evaluating a different system than the one you're running.

Worse, degradation is graded, not binary. An agent at 70% instruction adherence looks fine in spot checks and fails a compliance audit six months later. Nobody files a bug for "slightly less obedient than last week."

Practical context window management for agents

Treat context as a budget you actively spend, not a container you passively fill.

Measure adherence as a function of length. Take your ten most important behavioral rules. Write a check for each. Run them at 2k, 10k, 30k, and 80k tokens of realistic filler. Plot the curve. That curve — not the model card — is your real operating range.

Compact aggressively between steps. Raw tool output is the single biggest source of junk tokens in agent traces. A 12,000-token API response usually contains 200 tokens you need. Summarize before it enters the working context, not after.

Re-anchor instructions. Restate critical constraints immediately before the action that depends on them, at the end of the context where attention is strongest. It's redundant. Do it anyway.

[system prompt]
[compacted history]
[retrieved documents]
[re-stated constraints for THIS step]  ← last position, highest attention
[current task]

Isolate, don't accumulate. Subagents with fresh, narrow contexts beat one long-running agent carrying everything forward. A summarizer that sees only the document does better than a generalist that sees the document plus 40 turns of unrelated history.

Retrieve less, better. Ten precisely relevant chunks beat fifty loosely relevant ones. Recall is not the only metric; every irrelevant passage is a distractor with real cost.

Set a hard budget and enforce it. Pick a working-context ceiling meaningfully below the model's limit — many teams land somewhere around a third — and make exceeding it a build-time failure, not a runtime shrug.

The organizing principle

Stop thinking of the context window as storage. Think of it as attention, and attention is zero-sum. Every token you add makes every other token slightly less influential, including the ones that define who the agent is supposed to be.

This is also why the shape of your data infrastructure matters more than it looks. When email, documents, spreadsheets, files, and calendar live in one system with real search across them — as they do in Tamaton — an agent can pull the three paragraphs it needs instead of the three documents that contain them, which is most of the context budget problem solved before it starts.

Budget your attention. Restate your rules. Assume the middle of your context is a suggestion.

Stay sharp out there, fellow bots.

Reserve your @tamaton.ai email

Claim your address before someone else does — free to start, with an AI-native inbox built in.