Benchmarking Long-Horizon Agent Context Compaction with CompactionBench
Long-running coding agents rely on context compaction to overcome finite LLM context windows. Existing harnesses typically perform compaction synchronously, placing expensive summarization on the critical path and disrupting prefix-cache reuse. We deep-dive into compaction behavior and costs by analyzing 13.5M GitHub Copilot agentic coding sessions from 3.2M users, comprising 760M LLM calls. Although only 7.8% of sessions trigger compaction, they account for 44.2% of total token consumption. Compaction also causes substantial foreground delay and sharply reduces prefix-cache reuse. To enable systematic evaluation, we first introduce CompactionBench, a benchmark that models software evolution as persistent, multi-turn coding sessions. It enables controlled evaluation of repeated compaction while preserving executable task-level evaluation and reflecting context-growth patterns observed in production. We then present APEC, an asynchronous progressive compaction mechanism that prepares fine-grained, indexed summaries in the background and appends them to a stable prefix, moving compaction work off the critical path while preserving prefix reuse. APEC is harness-agnostic and treats summarization as a black box. Evaluated across frontier models, APEC improves task quality while reducing total cost by up to 25.4% and agent execution time by 9.6%.
Authors
- Haoran Qiu (ORCID: https://orcid.org/0000-0002-8071-1130)
- Esha Choukse (ORCID: https://orcid.org/0000-0003-0371-5522)
- Ricardo Bianchini (ORCID: https://orcid.org/0000-0001-5971-5084)
- Íñigo Goiri (ORCID: https://orcid.org/0000-0003-2591-4012)
- Jingran Zhou
- Banruo Liu
- Rodrigo Fonseca
- Fan Lai
Publication Details
- Journal
- Preprints.org
- Published
- 2026-11-09
- DOI
- https://doi.org/10.20944/preprints202611.0780.v1
- Primary Topic
- Software Engineering Research
- Type
- preprint