CliffCompaction: Cost-Efficient Compaction for Long-Horizon Coding Agents
Abstract
Agents often work on complex problems that require millions of tokens of context, which necessitates compacting across sessions due to limited context windows. We develop CliffCompaction, an autocompaction technique that reduces cost by up to 50% under a bounded context while maintaining or improving performance on Terminal-Bench and achieving new levels of efficiency for test-time scaling and state-of-the-art results on KernelBench. The per-rollout savings of CliffCompaction make the performance--cost trade-off of test-time scaling more efficient, adding over 10 percentage points on Terminal-Bench for less than the cost of two full-context runs. Under parallel test-time scaling, CliffCompaction lets Kimi K2.6 match Opus 4.7, and exceed Opus 4.6 and GPT-5.3 Codex at lower cost. The key to CliffCompaction's effectiveness is that it keeps compacted information faithful by only truncating or dropping content, never rephrasing or rewriting it. We never compact a compaction---each pass operates only on original content, and prior compacted output is discarded, preventing context drift from accumulating. These properties sustain continual learning over sessions exceeding a million tokens: on KernelBench, CliffCompaction reaches CUDA kernel speedups of after 200 steps and after 400 steps, surpassing specialized search algorithms and trained agents despite being a general-purpose compaction technique. We open-source a scaffold-agnostic API-proxy implementation of CliffCompaction usable with Claude Code, Codex and other harnesses.
Create a lesson
Metadata
- Categories
- cs.AI, cs.LG, cs.SE
Related papers
Stable Geometry with Divergent Task Evidence for Efficient Long-Horizon Agent Compression
Shared title terminologycs.AIMingxuan Wang, Fei Luo, Bo Wang et al.
DRSR: Learning Set-Level Deletion Risk for Efficient Long-Horizon Agents
Shared title terminologycs.AIMingxuan Wang, Bo Wang, Fei Luo et al.
DMC-5: Dual-Model Collaboration with Cache-aware Context Compression for Long-horizon Agents
Shared title terminologycs.AIHaochen Li, Xiaobing Tu, Yinggui Wang et al.
When Can Agents Forget Their Reasoning? ICLR for Long-Horizon Agent Context Compression
Shared title terminologycs.AIMingxuan Wang, Fei Luo, Bo Wang et al.
The Tasteful Agent: Measuring and Improving Taste in Long-Horizon Tasks
Shared title terminologycs.AIWenbo Pan, Zhichao Liu, Shujie Liu et al.
Do We Need Complex Topology Control? Distinct-Peer Random Routing Improves Cost-Efficiency in Sparse Multi-Agent Debate
Shared title terminologycs.AIBoxuan Wang, Zhuoyun Li, Xiaowei Huang et al.