A coding agent can spend much of its budget rereading its own tool history. Researchers at Carnegie Mellon University and Bosch tested a way to shorten that history without asking another language model to summarize it. In one Terminal-Bench 2.0 setup, their method cut average model cost per task from $0.40 to $0.19 while the share of tasks completed rose from 59.16% to 61.42%.
The method, called CliffCompaction, acts when a coding agent's conversation reaches a preset token limit. It drops long tool outputs, keeps short ones, and reduces older tool calls to compact signatures such as the tool name and key arguments. It retains the initial instructions and the most recent exchanges. Unlike a rolling summary, each later compaction discards the previous compacted block and works from the intervening history.
That choice trades memory of distant details for a more faithful record of what remains. The researchers say a coding agent can rerun a tool call if it needs information that was dropped. Their analysis of one Terminal-Bench configuration found that tool outputs and calls accounted for 84% of the context tokens before compaction, making them the main targets for reduction.
The team tested the approach on coding and terminal-task benchmarks with several model and agent setups. In the Terminal-Bench comparison above, Kimi K2.6 ran under the Terminus-2 agent harness. The $0.40 figure is the average cost per task with full context; $0.19 is the average with CliffCompaction triggered at 16,000 tokens. The completion rates are averages across the benchmark runs, not measured success in a workplace deployment. At a tighter 8,000-token threshold in that same setup, completion fell to 50.00%.
The results were not uniform. On SWE-bench Verified with the smaller mini-swe-agent harness, Kimi K2.6's average cost moved from $0.19 per issue with full context to $0.18 at a 32,000-token threshold, with task resolution changing from 73.87% to 73.27%. The paper says savings depend on the agent harness and task length, and it did not compare the method with systems that maintain a separate searchable memory.
The researchers have released an API-proxy implementation that can sit between a coding agent and its model service.
Sources
- CliffCompaction research paper, especially Sections 2–3, Tables 2–3 and Section 8.
- CliffCompaction code repository (MIT-licensed proxy implementation).
- Lead diagram: Figure 2 from the research paper, by Nguyen, Cho, Chen and Dettmers, CC BY 4.0; displayed without modification.