Context Rot: Why Your AI Coding Session Gets Dumber After 90 Minutes

Long agent sessions decay in a specific, predictable way. Better prompts do not fix it. Fresh sessions do.

Ash Rahman

Ash Rahman

Founder, BrainAI Team5 min read
Context Rot: Why Your AI Coding Session Gets Dumber After 90 Minutes

You start a coding session with an AI agent. First hour, it is sharp. It reads the files you point it at, writes code that mostly runs, catches its own mistakes. Around the ninety-minute mark something changes. It starts confusing filenames. It "fixes" a bug by adding a check that was already there. It apologizes for a mistake, then makes the exact same one two turns later. By the two-hour mark it feels like you are pair-programming with a tired stranger who has been reading over your shoulder all afternoon.

That is context rot. It is not the model getting worse. It is the context window filling up with noise until the signal cannot survive.

#What context rot actually looks like

The failure modes are consistent enough to be diagnostic. Learn to spot them and you save yourself the hour of frustration between "something is off" and "oh, this is the same thing that happens every time."

The agent starts referencing files or functions that do not exist. It confidently cites a path that was correct forty minutes ago but has since been renamed. It repeats a fix it already tried and abandoned. It contradicts a decision you and it made together earlier in the session, sometimes within the same reply.

Tool calls get sloppier. Bash commands that were carefully targeted at the start of the session become sprawling find invocations over the entire filesystem. The agent stops running the small verify step it was doing after every change. It skips the pre-flight it did an hour ago because "we already looked at that."

And the writing style shifts. Terse, precise updates from the first hour turn into apologetic multi-paragraph explanations. That is not a personality change. That is a model that has lost track of what the reader already knows.

#Why it happens

Two things are running at the same time and pulling in opposite directions.

The context window is finite. Every file the agent reads, every stack trace it processes, every tool result it receives is packed in. There is no forgetting, there is only summarizing, and summarizing loses information. By the time you are ninety minutes deep, half the window is unrelated to the current task. The signal-to-noise ratio has quietly collapsed.

At the same time, the agent has learned patterns from the session that stop being useful. Early on it followed a specific approach because that is what the task called for. Later, when the task has shifted, it keeps reaching for the same approach out of pattern-inertia. The agent is not confused about the current turn. It is over-fitted to a shape of work that no longer matches what you are doing.

Put those together and you get an agent that is technically responding to the latest prompt but really responding to an averaged-out summary of the entire session, filtered through a set of habits it picked up two hours ago.

#The fix is not better prompting

The instinct when the agent starts getting things wrong is to prompt harder. "Please read the file first." "Be careful with the imports." "Do not do X again." This does not work. You are trying to nudge a compass by shouting at it while standing on top of the magnet.

Every corrective prompt adds more tokens to the very context that is causing the problem. You get one turn of clarity, maybe two, then the rot compounds. The extra "be careful" instructions become their own noise, and the agent starts contradicting them the same way it was contradicting the original spec.

Longer prompts, better prompts, more examples, stricter instructions. All of them extend the runway. None of them fix the plane.

#What actually works

Kill the session.

Not "start a new conversation and paste in the whole history." That defeats the point. Write a short handoff, then throw away the poisoned context and start fresh from the handoff.

The handoff is three paragraphs, tops. What we are building. Where we left off. What the specific next action is. Include the file paths that matter. Do not include the reasoning history, do not include the abandoned approaches, do not include the earlier failed attempts. The new session should know what to do, not everything the old session ever knew.

Kick off the new session with the handoff as its first turn. You get back the sharp, precise agent you had at the start of the last session. The one that runs the pre-flight, reads the file before touching it, and writes code that runs the first time.

The whole cycle takes maybe three minutes and it happens every ninety minutes on long tasks. That is the actual workflow for agentic work over long horizons. Not one continuous marathon session. A chain of fresh sprints, joined by disposable notes.

#Making it habit

The first few times you do this, it will feel wasteful. You will have an agent that is only "a little off" and it will feel like giving up too early. Push through that. The tell is not that the agent is currently broken. The tell is that you are starting to work around it, adding qualifiers to your prompts, double-checking its work more than usual. When you are compensating, the rot has already set in.

Two practical patterns help.

Set a soft timer at seventy-five minutes. When it goes off, ask yourself honestly: is this session still crisp? If yes, keep going. If you have to think about it, it is not.

End every checkpoint with a handoff, whether or not you are going to use it. If you know how to write the "what we did, where we left off, what is next" summary at any given moment, you are in a state where you could rotate cleanly. If you cannot write it, that itself is a signal that the current context has gone muddy.

Agentic coding is not one long conversation. It is a series of short, well-scoped ones. The agents you can trust with real work are the ones you know when to kill.

Want to see this applied to a real team of agents running a business? Get started with a Free Technical Analysis and we will walk you through how our internal handoff protocol works.

Ash Rahman

Written by

Ash Rahman

Founder, BrainAI Team

Founder of BrainAI Team. I build autonomous AI agent teams that run real business operations for founders. Lead gen, content, support, and ops, handled by agents.

Newsletter

Get the next one in your inbox.

New teardowns, audits, and growth notes. No spam, no filler. Unsubscribe whenever you want.

Rather skip ahead? Work with us