Blog
What Is Context Rot — And Why It Makes Your AI Coding Tool Dumber Over Time
11 min read
You have probably experienced it without having a name for it. You start a Cursor or Claude Code session on a complex task. For the first fifteen or twenty messages, things go well. The model is following your conventions, building on decisions you made earlier, producing output that fits the system. Then something shifts. The AI starts contradicting itself. It re-suggests an approach you rejected forty minutes ago. The naming conventions from the beginning of the session disappear. The quality degrades, and not because the model got worse — but because the session accumulated enough state to confuse it.
That is context rot. The term was coined by developers in 2025 to describe a specific, reproducible failure mode in AI coding sessions. It is not random. It is not the model having a bad day. It is a structural consequence of how context windows work — and it gets worse as your sessions get longer and your codebase gets larger.
What context rot actually is
Every AI coding tool operates on a context window: a fixed-size buffer of text that the model can see and reason over at any point in a conversation. Early in a session, that window contains mostly your initial instructions, architectural guidance, and the first few exchanges. The model has clean context and produces clean output.
As the session grows, the window fills. Older content — your system prompt, your early architectural decisions, the conventions you established — gets pushed toward the edges of the window. Attention mechanisms in transformer models are not uniformly distributed across the full context length. They weight recent tokens more heavily than distant ones. So the carefully established conventions from message three are competing for the model's attention with everything that came after them, and losing.
Symptoms of context rot in a long AI coding session:
-> AI re-suggests a solution you already rejected 20 messages ago
-> naming conventions established at the start of the session disappear
-> a pattern the model was following correctly gets quietly abandoned
-> the AI introduces a new abstraction that contradicts one it just built
-> explanations become less specific and more generic over time
-> "I understand" confirmations that clearly are not backed by understandingThe insidious part is that the model does not announce this. It does not say "I have forgotten the naming convention we established." It just quietly drifts. From the outside it looks like hallucination or a quality regression. From the inside it is attention dilution — the signal you established getting buried under the noise of a long conversation.
Why it happens at the architecture level
Why context rot happens:
-> context window fills → older tokens get less attention weight
-> recency bias: the model favors what it last saw over what it saw first
-> no persistent memory: every session starts from zero
-> the repo never changes in the model's view, even as you make edits
-> long threads accumulate ambiguous state the model can't resolve cleanlyThe deepest cause is the third item: no persistent memory. Every AI coding session starts cold. The model has no memory of what you built yesterday, what decisions you made last sprint, what conventions the team agreed on, or what the system actually does. Whatever ground truth the model operates from must be re-established in every session — through your system prompt, through manually included files, through CLAUDE.md, through the early messages of the conversation.
That re-established context is all the model has. And as the session grows, it competes with everything else in the window. The longer you work, the more the initial grounding gets diluted. By the time you are deep in a complex feature, the conventions from the start of the session are the least-attended content in the context window.
This is related to but distinct from the broader problem of context windows not being enough for large codebases. Even if context windows grow to accommodate more code, they cannot fix recency bias. A model given 2 million tokens of codebase will still attend more to the last thousand tokens than to architectural decisions established at token 50,000.
What developers currently do about it
The workarounds are consistent across Reddit threads, developer forums, and community discussions. They all share a common property: they are friction-generating patches on top of a structural problem.
What developers do to fight context rot (and why it falls short):
-> "one session per task" — constant session restarts, constant re-grounding
-> summarize the conversation and paste it into a new session
-> manually re-add architectural context every few messages
-> use /clear or /compact and rebuild context from scratch
-> keep sessions under 30 messages as a rule of thumb
All of these are symptoms of the same root cause:
there is no persistent, grounded source of system truth to anchor the session.The "one session per task" heuristic is probably the most widely shared advice. Start a new session for each discrete task rather than letting a single session accumulate state over hours of work. This limits how much rot can build up, but it also means you are re-establishing context from scratch every time you switch tasks. The cost of that re-establishment is real — it is time, it is manual effort, and it is prone to omission.
The summarize-and-restart approach is more aggressive but more thorough. You ask the model to summarize the current state of the system, architectural decisions made, and conventions in use, then paste that summary into a fresh session. This works reasonably well for well-defined tasks but requires discipline and loses the full thread of reasoning that got you to the current state.
None of these workarounds address why the rot happens in the first place: there is nothing persistent and external for the model to anchor against. The session state is the only source of ground truth, and session state decays.
The architectural insight that changes the fix
Context rot is not primarily a context window problem. It is a context source problem. The thing rotting is not just the conversation — it is the fact that the conversation is the only source of system truth the model has access to. When the conversation degrades, nothing else remains to anchor the model's understanding.
The fix is not to fight the degradation of the conversation. It is to give the model a stable, external, persistent source of ground truth that does not live inside the conversation at all. Something that gets queried at need, not accumulated over time. Something that does not dilute as the session grows, because it exists independently of the session.
That is what a semantic codebase layer via MCP actually does. Instead of loading your entire architectural context into the initial prompt and hoping it survives the session, you give the model a tool it can call to retrieve current, accurate system understanding at any point in the conversation — regardless of how long the session has run or how much context has accumulated.
What a grounded session looks like:
-> new session opens with semantic context already loaded from the index
-> the model knows your service topology before you type the first message
-> architectural conventions come from the actual codebase, not the chat history
-> adding more messages does not dilute the system understanding
-> you can start fresh without losing everything — because the ground truth persistsThe practical difference is that the model does not need to hold your entire system architecture in context to reason correctly about it. It can query the semantic index when it needs to verify a convention, trace a dependency, or understand where a workflow lives. That query returns fresh, accurate context — not the degraded version that has been sitting in the window since message three.
Context rot gets worse as codebases grow
There is an interaction effect worth naming explicitly. Context rot compounds with codebase complexity. On a small project, the conventions are simple enough that the model can re-derive them from local context even after the initial grounding degrades. On a production system with multiple services, shared libraries, architectural conventions accumulated over years, and cross-service workflows — the model cannot reconstruct that from local inference. When the grounding degrades, the output degrades significantly.
This is part of why Cursor and Claude Code fail in large repositories at rates that surprise developers who have only used them on smaller projects. The tools work well when the relevant context is local. They degrade when the relevant context is architectural, cross-service, or accumulated over time. Context rot accelerates that degradation by eroding even the partial grounding that was established at the session start.
For teams, context rot is a consistency problem
Individual context rot is annoying. Team-level context rot is an architectural risk. When every developer starts fresh sessions without persistent grounded context, the conventions the model operates from vary not just across sessions but across team members. One developer establishes one pattern in their CLAUDE.md. Another has a different summary. A third just started and has not written one yet. The AI produces code that is consistent within a session but inconsistent across the team.
A managed, team-wide semantic codebase layer solves this at the source. Instead of each developer individually managing their context strategy, the team shares a single indexed representation of how the system actually works. Every session, for every developer, starts from the same ground truth. Context rot still happens at the session level — the window still fills, recency bias still applies — but the starting point is always grounded, not dependent on what each individual developer remembered to include in their CLAUDE.md last week.
Final take
Context rot is real, it has a name, and it is getting discussed more as developers spend more time in long AI coding sessions on complex codebases. The symptom is the AI getting worse over time. The cause is a context window with no external anchor. The fix is not to restart sessions more aggressively. It is to give the model a persistent, queryable source of system truth that does not live in the conversation.
The session can rot. The index cannot. That is the architectural principle that separates tools that patch around context rot from tools that address it structurally. If your team is spending time fighting AI drift in long sessions, the answer is not better prompt discipline. It is better context infrastructure.