Sub topic 3
How Long Sessions Go Wrong: Symptoms of a Crowded Context
This chapter assumes you have used a coding agent for real tasks, know the command line and git, and understand that a model reads a limited number of tokens at once. It covers how a crowded context shows up in the agent's behavior, so you can spot it early and act before the window is full.
Why a full window is not the only problem
A session can go wrong well before the context window is full. The model still reads everything in the window, but its attention is spread across a lot of text. Old file dumps, long logs, and abandoned approaches compete with the instructions and facts that matter now. The result is gradual: the agent gets a bit less reliable with each turn, and you may only notice once it makes a clear mistake.
Two forces cause this:
- Dilution. Relevant facts sit among large amounts of irrelevant text, so the model is more likely to miss or underweight them.
- Truncation or compaction. When the window fills, the tool drops or summarizes old content. Details that were never written down elsewhere can disappear.
The common symptoms
| Symptom | What you see | Likely cause |
|---|---|---|
| Forgotten decisions | The agent proposes an approach you already rejected | The decision is far back in the history or was lost in a summary |
| Repeated work | It re-reads files or reruns a search it already did | It no longer "sees" the earlier result clearly |
| Drifting instructions | It ignores a rule from the project instructions, such as a naming convention | The rule is buried under newer, larger content |
| Contradictions | It states one thing about a function, then the opposite | Two versions of the file are in context, before and after an edit |
| Invented details | It cites a function or flag that does not exist | The real code is no longer in view, so it guesses |
| Slower, vaguer replies | Responses get generic or hedged | Many competing signals and little focus |
| Looping | It tries the same failing fix several times | Earlier failed attempts are not weighing against the next try |
No single symptom proves the context is crowded. Check the cause before you blame it. A repeated mistake can also come from an unclear request or a real bug. The strongest signal is a cluster of these symptoms appearing late in a long session after the agent was working well.
A worked example
Suppose you are migrating a settings loader and you decided early on to keep load_settings() unchanged. Three hours and a few hundred tool calls later, you see this:
- The agent edits
load_settings()to take a new argument. - You remind it of the decision, and it apologizes and reverts.
- Twenty minutes later it suggests the same signature change again.
The decision was made once, in conversation, and everything since has pushed it further back. The fix is not to repeat yourself more loudly. The fix is to put the decision somewhere durable, such as a notes file or the project instructions, and to reduce what surrounds it. Later chapters cover those techniques.
Catching it early
Do not wait for a hard error. Watch for these signs:
- You find yourself repeating an instruction you gave earlier.
- The agent re-reads a file it opened recently.
- A reply contradicts something from earlier in the same session.
- The session has covered several unrelated subtasks.
Exercise
Late in a long session, the agent re-suggests a design you rejected two hours ago, and it also invents a config option that is not in your code. Name the two symptoms and one step you would take.
Show answer
The symptoms are a forgotten decision and an invented detail, both signs of a crowded or compacted context. A good step is to record the decision in a notes file or the project instructions, then compact or start a fresh session so the agent reads the real code and the written decision again.