Context Rot: Why AI Coding Agents Get Worse the Longer They Work

Context Rot: Why AI Coding Agents Get Worse the Longer They Work

Have you ever let Claude Code or some other AI agent debug an issue for half an hour, only to notice it kept repeating the exact fix that already failed? AI researchers call this context rot, the way an AI's output quality drifts the longer it works, even when its memory is nowhere near full, and a new explainer video on the Prompt Engineering YouTube channel (posted 2026-11-28) breaks it down clearly. The video uses a familiar example: a coding agent asked to migrate a codebase to a new database driver, stuck going in circles.

What context rot actually is

"Context" is everything you and the AI have exchanged in a session: your questions, its answers, file contents it read, command output it ran. Every AI today has a hard limit on how much context it can hold, but the part people miss is this: the AI does not need to hit that limit to start performing worse. Just making the context longer quietly lowers answer quality, the same way a messier room makes it harder to find the right thing even before the room is actually full.

5 ways context breaks down

Drew Breunig, whose writing on context management is widely cited among AI engineers, identified the first four failure modes. This video lists a fifth, matching a phenomenon separate 2025 research on long-horizon agent execution calls "self-conditioning" (Sinha et al., arXiv:2509.09677). Put together, these are the five ways context breaks down:

  • Poisoning: the AI guesses wrong or hallucinates a detail, that detail lands in the context, and the AI keeps treating it as fact and repeating it in later steps.
  • Distraction: a context grown too long makes the AI over-focus on recent chat history, forgetting what it learned during training, repeating the same old move instead of trying something new.
  • Confusion: too much irrelevant information or too many unrelated tools sit in the context, leading the AI to pick the wrong response.
  • Clash: two contradictory pieces of information both exist in the context (say, an old instruction that was never removed after a new one arrived), and the AI cannot tell which one to trust.
  • Self-conditioning: the newest and most notable one. When the context still holds the AI's own earlier failed attempts, it tends to repeat them. That 2025 study (arXiv:2509.09677) found this does not go away just by scaling up to a bigger model, but models that think before answering get stuck in this loop less.

A different fix for each failure mode

The good news is each failure mode has a matching fix, and this is also the direction many modern AI coding agents are heading, for instance some already ship a command to compact conversation history so you can clear context on your own terms:

  • For poisoning: validate a conclusion before it gets locked into context, instead of trusting it right away.
  • For distraction: compact the conversation history once it gets long, summarizing what matters and dropping the rest.
  • For confusion: give the AI only the tool loadout it needs for the task at hand, like a soldier packing only the gear a mission calls for instead of the whole armory.
  • For clash: prune outdated information once something newer replaces it, instead of letting both versions linger.
  • For self-conditioning: the most effective fix is not asking the AI "are you sure", it is cutting out the chunk of history that holds the failed attempt, or starting a clean session altogether. Reasoning models that think before answering also get stuck in this loop less.

What this means for you

If you use AI for coding, writing or any long multi-step task, here is what you can do today:

  1. When the AI keeps repeating a fix that is not working, do not keep explaining in the same conversation. Open a new session, or ask it to summarize first and continue from that clean summary.
  2. Break long tasks into steps with checkpoints, instead of handing over one giant request and letting the AI run unattended for hours.
  3. If your AI tool has a command to clear or compact context (many coding agents do), use it on a regular basis instead of waiting until the agent is already tangled up.
  4. Do not automatically trust every conclusion the AI writes into its own "memory." One wrong detail early on can get repeated verbatim twenty steps later.

Knowing these five failure modes makes it a lot less frustrating when your AI agent stalls out mid-task, and tells you exactly what kind of fix to reach for instead of just saying "that's wrong, try again." It is also part of the broader skill of context engineering that anyone serious about using AI should pick up, especially if you rely on Claude Code for multi-hour projects, or ask AI to make sense of a large codebase.

FAQ

Is context rot the same as running out of context window? Not quite. Running out of context window means you hit the technical limit. Context rot is the gradual quality drop that happens even while there is still room left, caused by noisy, repetitive or contradictory content.

Do stronger AI models suffer less from context rot? Not necessarily. For self-conditioning specifically, simply using a bigger model does not make this go away on its own; models that think before answering handle it better.

Does this matter for non-coders too? Yes. This shows up in anything an AI does across many connected steps, such as writing a long outline, planning a multi-stage project, or automating office work, not just writing code.

How do you know an AI is experiencing context rot? The clearest sign is the AI repeating the exact approach that already failed, giving increasingly generic answers, or seeming to "forget" something you stated clearly earlier in the same conversation.

#AI #ContextRot #AIAgent #ClaudeCode #VibeAICoder

More articles