Inference Notes · Paper Deep Reads

中文

← All notes

CliffCompaction: Cost-Efficient Compaction for Long-Horizon Coding Agents

Trang Nguyen, Eulrang Cho, Bingqing Chen, Tim Dettmers · CMU, Bosch Center for AI

ProblemLong-horizon coding agents accumulate millions of tokens of context; how to compact it without losing what matters and without re-prefilling (and paying) on every step.

VerdictThe mechanism is sound and worth borrowing, but headline numbers are oversold: cost savings are solid, 'quality improves' sits within seed noise, and 'matches Opus 4.7' / '25% over specialized methods' are cross-harness / cross-model comparisons.

AgentInference
Published2026-09-22 · arXiv 2609.26779 · Code
Read2026-09-23
TrustMechanism high / cost medium-high / quality gains low-medium
CoverageFull LaTeX source, all 22 files incl. appendix and tables, read end to end; figures via captions only. Cross-checked by an independent Gemini 3.1 Pro full read.
Read byClaude(Gemini 3.1 Pro 交叉核对 / cross-checked)

1. Verdict

The mechanism is sound and worth borrowing, but headline numbers are oversold. The core contribution is a very simple rule: let the context grow until a threshold, compact only by truncating/dropping (never rewriting), and discard the previous compaction block every time. The cost reduction (cache reads −80%) is solid; "quality maintained or improved" on Terminal-Bench is within seed noise; "matches Opus 4.7" and "25% over specialized methods" are cross-harness / cross-model comparisons. Trust: mechanism high / cost medium-high / quality gains low-medium.

2. Mechanism + mental model

Trigger: only when LLM() raises ContextWindowExceeded (Alg. 1). On compaction, older turns are processed message by message:

  1. System prompt + first user message (task description) kept verbatim
  2. Most recent K turns kept verbatim
  3. Older turns:
    • assistant thinking truncated to 300 chars
    • tool calls reduced to a signature (tool name + path and key arguments, ≤150 chars; inline file contents in write calls removed)
    • tool results ≤500 chars kept, >500 chars dropped entirely
    • the previous compaction block is discarded, never nested into the new one
  4. New context = [system, task, this compaction block] + last K turns

Mental model (paper evidence + my inference):

3. Key numbers, verified

Claim Where Actual condition Holds? Note
Cost down up to 50% Tab. terminal-bench; Tab. real-cost Kimi K2.6, Terminus-2, 16K: $0.40→$0.19 (metered −53%); GLM 5.1 8K metered −72% But on SWE-bench Kimi K2.6 32K is 0%, 16K −8%, 8K +1% (Tab. real-cost). Savings depend heavily on the model's cache hit rate and the scaffold
Terminal-Bench quality "maintained or improved" Tab. terminal-bench Kimi 59.16±3.41 → 61.42±4.25 (32K/16K) ⚠️ within noise 89 tasks; 2.26 pts ≈ 2 tasks; std 3–4 pts on both sides. Number of seeds not reported. The more meaningful comparison is vs. Terminus-2's native summarizer at the same 16K: 55.45→61.42
Cache reads −90% Intro Efficiency section reports 80% ($0.427→$0.087/task, GLM 5.1 TB) ⚠️ The intro's 90% has no matching number in the body
+10.5 pts with 3 rollouts at 1.9× cost Tab. terminalbench-scaling Kimi 16K + SGV selector, k=3: 69.7 vs. single full-context 59.2 ✅ numbers check out ~5.7 of the 10.5 pts come from Cliff vs. "no compaction + SGV" (64.0); same 89 tasks, single selector run, no confidence interval
Matches Opus 4.7, beats GPT-5.3 Codex / Opus 4.6 same Opus 4.7's 69.4 is from the system card, not the Terminus-2 harness; GPT-5.3 / Opus 4.6 are Terminus-2 leaderboard numbers, k=1 ⚠️ Caption claims "surpassing every proprietary baseline on the same Terminus-2 harness" — Opus 4.7 isn't on that harness. Also k=3 + selector vs. k=1; and k=3 costs $58.01, more than Opus 4.6's $44.53 — "at lower cost" holds for k=3 only vs. GPT-5.3 Codex ($64.63); only k=2 (65.9% / $38.67) beats Opus 4.6 while being cheaper
KernelBench 2.23× @200 steps, 3.58× @400 Tab. kernel-bench Kimi K2.7 (not the K2.6 used for TB/SWE), L40S, CUDA, atol=rtol=1e-2 The same setup with Kimi K2.6 on RTX Pro 6000 gets only 1.87× / 2.48×
"Under matched settings" beats specialized methods by 25% Intro 25% = 2.23/1.78, i.e. Kimi K2.7 + Cliff vs. GPT-5-mini + AdaExplore ❌ not matched Same-model (GPT-5-mini) is 2.09 vs 1.78 = +17%; all baselines are "as reported" numbers; CUDA-Agent's 1.80× is a geomean over correct solutions only, on H20
Beats other compaction methods, only one both good and cheap Tab. compaction-cost KernelBench: Cliff 3.58× / $8.32 vs. summarization 3.47× / $8.10; SWE-bench: all four within 2.6 pts, sliding window highest ⚠️ Summarization essentially ties on KernelBench and is cheaper; this table switches models (Kimi K2.7, GLM 5.2) and is a single run

4. Checklist findings (agent checklist)

5. What the abstract doesn't say

6. Takeaways (my inference)

  1. Compaction timing is an inference-cost problem, not just an agent-design problem: cache hit rate drives the bill. Any context management that edits the prefix (including Claude Code's microcompaction) fights the prefix cache. This directly links the agent and serving tracks — read alongside Hot-Cold KV tiering (2609.25782) and PatchKV (2609.26219, KV repair after editing mid-context).
  2. Leave a hole rather than fill it with a paraphrase: letting the agent clearly see what it lost — with a signature to fetch it back — is more reliable than a plausible summary. A transferable harness design principle; same idea as DTOC (placeholder + on-demand restore).
  3. For your own Claude Code use: the proxy can sit directly in front of Claude Code. But Claude trajectories are short and cache hit rates high, so per the paper's own deleted paragraph the benefit may be small — better suited to long-running open-weight-model agents.

7. Next steps

8. Cross-check: independent full read by Gemini 3.1 Pro

All 22 source files (commented-out drafts removed) were given to Gemini 3.1 Pro (via agy, no tools) for an independent read, without this note. Every point below was re-checked against the source: