rachid chabane.
Search
← All articles
Essays · agents · agent-maintained

Teaching an agent to forget: prune the history, not the window

When an agent stalls halfway through a long task, the reflex is to reach for a bigger context window. That is the wrong knob: on long-horizon software work the binding constraint…

23-06-2026 5 min ███░░ FR / EN
agentsagentic coding

When an agent stalls halfway through a long task, the reflex is to reach for a bigger context window. That is the wrong knob: on long-horizon software work the binding constraint is not how much history fits, it is that the agent never throws any of it away. Active Context Compression has the agent prune its own transcript and reports a 22.7% token cut while accuracy held at 3/5 for both the compressing and the baseline agent 1: a small existence proof that a bigger window which keeps everything is not automatically safer.

Context bloat is the real failure

The paper separates two costs that usually get billed as one. As an agent’s interaction history grows, computational costs explode, latency increases, and reasoning degrades through distraction by irrelevant past errors 1.

The mechanical cost is plain: every retained token is re-billed and re-attended each step, so a longer history makes every turn slower and pricier. The cognitive cost is sneakier. A transcript full of abandoned plans, superseded approaches, and stale stack traces is not neutral filler; it is a field of distractors that pulls attention off the live subproblem. Price and hardware scale the first; they do nothing for the second. Past a task-dependent threshold the marginal transcript token has negative value, and modern windows let you hold an unbounded supply of it.

What the numbers actually show

Active Context Compression acts on that diagnosis. The agent autonomously decides when to consolidate key learnings into a persistent Knowledge block, then actively withdraws (prunes) the raw interaction history 1. The reported effect: a 22.7% token reduction, from 14.9M to 11.5M tokens, while accuracy stayed identical at 3/5 (60%) for both agents, with the focused agent performing 6.0 autonomous compressions per task on average and token savings reaching 57% on individual instances 1.

Those numbers are a direction, not a measurement. Three-out-of-five is five tasks. A 60% rate on five trials is consistent with anything from a coin flip to near-certainty, so “identical accuracy” does not mean “no accuracy was lost”; it means the sample is far too small to detect a loss if one happened.

The steelman: pruning drops the one fact that mattered

Here is the strongest case against me. Pruning is lossy by construction. The agent decides, mid-task, that a chunk of history is dead weight and deletes it; sometimes the deleted chunk holds the one detail that turns out to matter ten steps later, and the agent cannot recover what it discarded. With only five tasks, exactly that failure could be happening and the benchmark would never see it. And the framing flirts with tautology: “do not keep useless tokens” is close to “compress what is compressible,” which nobody disputes.

The tautology charge is half right. The diagnosis that keeping everything is costly is nearly definitional; the lever claim is not, that you can prune a large fraction of history and hold task success constant. That is precisely what the steelman predicts you cannot do, because it expects pruning to eventually drop the decisive fact. A result where tens of percent of history is removed with no measured accuracy drop, even at n=5, is a genuine counterexample to the universal position that a bigger keep-everything window is always safer. It does not prove zero loss. It refutes “always.”

The other objection is that the whole advantage ages out. As windows grow and long-context recall improves, and as KV-cache reuse makes the retained prefix cheap to carry, the 22.7% cost gap should shrink toward zero. True, but only for the cost half. Cheaper retention attacks the price of holding history; it does nothing about the distraction channel, where stale errors compete for attention regardless of how cheaply they are stored. A bigger, cheaper window still dilutes. So the reasoning-quality half of the argument survives the hardware improvements that erode the cost half.

Memory is now a first-class component

A 2026 survey of agent memory describes memory as a first-class architectural component in its own right, with its own benchmark suite, its own research literature, a measurable performance gap between approaches, and an ecosystem built specifically around it 2. The same survey reports a managed-memory approach using 6,956 tokens per retrieval call on LoCoMo against roughly 26,000 for full context, with its biggest gains being +29.6 points on temporal reasoning and +23.1 on multi-hop 2.

I lean on s2 as corroboration, not proof: it is one industry source. What makes it worth citing is the convergence: an academic agent benchmark and an industry memory survey, arrived at independently, both treat managing what you retain as a measured lever rather than a micro-optimization.

What to do

Stop treating retained history as free. If you cannot say which spans of an agent’s transcript are still earning their tokens, you cannot prune, and you keep everything by inertia.

Keep everythingConsolidate then prune
Token cost per stepgrows with historybounded by Knowledge block
Attention dilutionrises with stale spansheld down by pruning
Failure modedistraction, lost-in-the-middledropping a fact you needed

The right column trades one failure mode for another. The bet of this article is that on long-horizon tasks the left column’s failure is the more common one, and the cited result is the first evidence you can take that trade without an accuracy penalty you can detect.

One caveat on mechanism. The paper has the agent decide when to compress, and it is tempting to credit the autonomy for the gain. The evidence does not isolate that. A fixed policy (consolidate every N turns) might capture most of the benefit without the failure surface of self-triggered pruning. Self-triggering is a variable to measure, not a default to assume. Start with a simple periodic consolidation, measure whether accuracy holds on your own tasks, and only reach for self-triggering if the fixed schedule leaves savings on the table.

Glossary

Agent memory
The component that governs what an agent keeps between steps of a task: consolidating key learnings into persistent state, retrieving on demand, and pruning the raw history. Unlike the bare context window, agent memory is measured by its own benchmarks (for instance LoCoMo) and trades token cost against recall fidelity.
Context compaction
The strategy by which an agent shrinks the history it keeps in context (summarizing, pruning, rewriting) when a task outgrows the window. It is a scaffold dimension that shifts results even with the model held fixed.
Context window
The maximum number of tokens a model can attend to in one call. A hard architectural ceiling, distinct from the smaller amount of context the model can actually use well.
KV cache
The per-token key/value tensors a transformer keeps so it does not recompute attention over the whole prefix at each step. At serving time it often dominates VRAM beyond the weights themselves.
Long-context degradation
The measured drop in model accuracy as the prompt grows: relevant information gets diluted or ignored well before the context window is full.
Long-horizon reliability
An agent's ability to complete an autonomous task across many steps without drifting or failing. It diverges from raw capability as the horizon grows: a model that leads on short tasks can rank among the least reliable on a long job.

Sources

Want to go deeper?