Beyond Compaction: structured context eviction for long-horizon agents
Andrew Semenov, Svyatoslav Dorofeev · Kiz8
We present Context Window Lifecycle (CWL), a context-management scheme that gives long-horizon LLM agents an effectively unbounded working horizon. As a session accumulates history, CWL keeps the context within budget through graduated, semantically-aware eviction: the agent annotates its trajectory as typed, dependency-linked episodes as work proceeds, and a deterministic, LLM-free policy evicts content in priority order within that structure when a token budget is exceeded.
- Question
- Can one long-running LLM agent keep working without losing coherence once its history outgrows the context window, without summarising that history away?
- Method
- Context Window Lifecycle (CWL). The agent annotates its own trajectory as typed, dependency-linked episodes while it works. When the token budget is exceeded, a deterministic, model-free policy evicts content in graduated levels, oldest-and-most-recoverable first, and never drops context an open action still depends on.
- Experiment
- Every task of four benchmarks (Terminal Bench 2.0, a 50-task SWE Bench Lite sample, Recovery Bench, LongCLI Bench) run back to back in a single uninterrupted session under an 80,000-token budget, against the standard fresh session per task. GPT-5.4; five runs on Terminal Bench 2.0, three elsewhere.
- Findings
- No measurable degradation in accuracy: the two conditions differ by at most 3 points, within run-to-run variance (Terminal Bench 2.0: 68.25% with CWL, 68.40% baseline). One session completed 89 sequential tasks across more than 80 million tokens, at about $55 per run.
- Limitations
- Dependencies attach to whole exploratory episodes, not individual tool calls. The design assumes one linear stream of episodes. The annotation protocol may change how the model explores (rushing in some sessions, looping in others), which the authors could not isolate. Larger evaluations are planned for a follow-up.
- CWL · one session
- Baseline · fresh session per task
| Benchmark | CWL | Baseline | Δ pts |
|---|---|---|---|
| Terminal Bench 2.0 · n=5 | 68.25 | 68.40 | −0.15 |
| SWE Bench Lite · 50 tasks · n=3 | 43.00 | 40.00 | +3.00 |
| Recovery Bench · n=3 | 66.80 | 69.75 | −2.95 |
| LongCLI Bench · n=3 | 20.00 | 20.00 | 0.00 |
The comparison is deliberately asymmetric: CWL runs every task in one session, the baseline starts fresh for each task. The principal result is parity under the harder regime.
@misc{semenov2026beyond,
title = {Beyond Compaction: Structured Context Eviction for Long-Horizon Agents},
author = {Semenov, Andrew and Dorofeev, Svyatoslav},
year = {2026},
eprint = {2606.11213},
archivePrefix = {arXiv},
primaryClass = {cs.CL},
doi = {10.48550/arXiv.2606.11213}
}