Blog

Context rot: why long agent runs lose the thread.

A run that starts sharp can end sloppy without ever throwing an error. The context swells, the original instructions get buried, and the agent starts improvising.

Reference documents and notes stacked for a long working session
Context rot

November 19, 2026 · 6 min read

Ask an agent to do a short job and it usually does it well. Ask the same agent to work for three hours, across dozens of tool calls, and something quieter happens: the answers stay fluent, the work keeps moving, and the original goal slowly stops being the thing the agent is actually doing. Nobody changed the instructions. The instructions just got buried under everything that came after them.

That is context rot. It is not a model failure in the usual sense, and it does not show up as an error. It shows up as a run that re-does finished work, invents a detail it forgot it already checked, or quietly drops a constraint from the first message — the one that said, in plain language, do not do exactly the thing it is now doing.

What actually rots

Three things degrade as a context grows. First, recall: the model can still see the early messages, but they carry less weight against the recent ones. A rule stated at the start competes with fifty tool outputs that arrived later. Second, precision: long transcripts are full of near-duplicates, dead ends, and corrected mistakes, and the model has to decide which version of the facts is current. Third, judgement: as the run gets longer, the agent has more history to rationalise from, so a wrong turn looks more reasonable — it can point to something in the transcript that seems to support it.

The practical sign is not confusion. It is confidence. A rotted run does not ask for help. It proceeds, smoothly, in the wrong direction. That is why context is an operations problem, not just a prompt problem: the fix has to live outside the agent, in how the run is structured and watched.

Keep the working set small

The simplest defence is to stop feeding the agent everything. A run should carry a working set — the goal, the current state, the open questions, and the evidence that matters — and leave the rest in a store it can retrieve on demand. Tool outputs should be summarised at the point of capture, not pasted in full. A file listing is a summary; a log tail is a summary; a search result is the three relevant passages, not the whole page.

Retrieval beats stuffing for the same reason a desk beats a warehouse: the agent works better with the five documents it needs than with the five hundred it might need. When a run genuinely needs a large document, fetch the section, not the file. When it needs history, fetch the decision log, not the raw transcript.

Compaction is a checkpoint, not a shredder

Every long run needs planned compaction points: moments where the agent stops, writes down what it knows, and restarts from a clean summary. A good compaction keeps the goal verbatim, the constraints verbatim, what has been done and verified, what is still open, and what was tried and ruled out. A bad compaction keeps the narrative and drops the constraints — which is how a run comes back from a summary believing it has permission it never had.

Write the compaction down where a human can read it. If the summary is only ever read by the next model call, nobody will notice when it starts drifting. If it is logged, a reviewer can compare the summary against the original brief in seconds, and that comparison is one of the cheapest checks in agent operations.

# compaction checkpoint, logged out-of-band
goal: verbatim from the original brief
constraints: verbatim, not paraphrased
verified: done, with evidence
open: still to do
ruled_out: tried, failed, do not retry blindly

Watch the shape of the run

Context rot leaves traces in telemetry before it leaves traces in output. Context size climbing without the task getting closer to done. Tool calls repeating the same query with slightly different wording. The agent re-reading files it already read. Verification steps getting skipped as the run gets longer. Any one of these is a reason to pause the run and look, not a reason to let it keep going because it has not errored yet.

The operational rule is simple: a long run is a series of short runs, with a human-readable checkpoint between them. Break the work into steps that can each be verified on their own. Put the constraints where they cannot be buried — restated at each checkpoint, not just at the start. And when the context has grown past the point where the agent can still name the goal and the constraints without looking them up, end the run and start a fresh one from the checkpoint. A fresh run with a clean brief beats a long run that has forgotten what it was asked to do.

← Back to all posts
Open the Watch → Join the waitlist