Here's a bug you've probably felt without being able to name it. A long coding-agent session is going fine, then somewhere past the hour mark it gets weird: it re-applies an edit it already made, or forgets a command it just ran, or announces it's going to do a thing it did five minutes ago. You blame the model. Often the real culprit is quieter, and this week Cline shipped a fix that names it.
In CLI v3.0.41 (July 15, 2026), two lines: "Compaction no longer runs during an active turn" and "Compaction now shows progress status in the TUI." The SDK's v0.0.61 adds that compaction now reports progress while it runs. One-line changelog entries. A real lesson underneath.
Compaction is a rewrite of the agent's memory#
Every agent that runs long has to solve the same problem: the conversation grows, the context window doesn't. Compaction is the fix — condense or summarize the older turns so the session keeps fitting. It's not optional; without it, a multi-hour task simply runs out of room.
But notice what compaction is: it edits the agent's working memory in place. It throws away the verbatim history and replaces it with a shorter paraphrase. That's fine when the agent is idle between turns. It is not fine when the agent is in the middle of one.
The gap where it goes wrong#
A single "turn" is rarely a single step. It's a little sequence: the model emits a tool call → the tool runs → the result comes back → the model reads the result and reacts. That gap between call and result is where a naive compaction scheduler can fire, because that's exactly when the model is "thinking" and the loop looks idle.
If compaction runs in that gap, it can summarize away the message that issued the pending call. Now the tool result comes back and folds into a context that no longer mentions the action that produced it. The model's options are all bad: treat the result as unexplained, re-issue the call it can't see it already made, or drop the thread entirely. Those are the exact "weird" symptoms — the duplicated edit, the forgotten command, the re-decided plan.
Compaction isn't only a token-budget problem. It's a scheduling problem — and the schedule that matters is: never mid-turn.
Cline's fix is precisely that scheduling rule. Compaction is held until the current turn completes, so the in-flight action always resolves against stable context. The second half — showing progress in the TUI — matters too, because a compaction pass that used to look like the agent silently hanging now shows its work. A stall you can see is a bug report; a stall you can't is a shrug and a restart.
The rule generalizes past Cline#
This is the part worth keeping if you never touch Cline. If you build any agent loop that summarizes context to stay in the window — a custom harness, a LangGraph graph, your own while-loop around a model call — the discipline is the same:
- Compact at turn boundaries, never inside one. Treat "model has a pending tool call" as a hard no-compaction zone. Wait for the result to land and the turn to close.
- Make compaction observable. Emit a status so a long pass reads as progress, not a hang. Your future self debugging a stuck session will thank you.
- Pair it with a checkpoint. If you're on LangGraph, a turn boundary is also the natural place to checkpoint, so a compaction-or-crash line is a clean resume point rather than a corrupt one. Compaction and durable resume are the same boundary problem seen from two sides.
It rhymes with the broader question of how you steer a running agent: any time you mutate an agent's state while it's mid-thought — injecting a message, flipping a mode, rewriting its history — you have to respect the turn boundary or you get incoherence. Cline made that concrete for one of the three things that mutate state. (It also, in v3.0.37, made plan/act mode switches visible to the model, which is the same principle applied to a different mutation: if you change the rules mid-session, tell the agent.)
If you're weighing Cline against the field, this is the kind of unglamorous reliability work that separates a demo from a daily driver — the sort of thing worth reading next to Aider vs Cline vs OpenHands and Claude Code vs Cursor vs Cline. Nobody screenshots "compaction now waits for the turn to finish." It's just the difference between an agent that holds together for three hours and one that starts arguing with its own history at hour two.



