Carnegie Mellon University · 2026-09-22 · major
CliffCompaction — a drop-in proxy that halves long coding-agent costs
CliffCompaction is an API proxy that trims a coding agent's history once it passes a token limit, cutting cost by up to 50%. It only truncates or drops text, never rewrites it, and works with Claude Code and Codex CLI unchanged.
An API proxy that keeps long coding-agent sessions inside a token budget without touching the agent.
Key specs
| Cost reduction | Up to 50% |
|---|
Quick facts
| Makers | Carnegie Mellon University and Bosch Center for AI |
|---|---|
| License | MIT |
| Package | cliffcompaction 0.1.0 on PyPI |
| Works with | Claude Code, Codex CLI, Anthropic Messages, OpenAI Chat Completions and Responses |
| Default threshold | 200,000 tokens |
| Paper | arXiv:2609.26779, 22 September 2026 |
Benchmarks
| Full context | 73.87% | |
|---|---|---|
| CliffCompaction at 32K | 73.27% | |
| CliffCompaction at 16K | 71.87% | |
| CliffCompaction at 8K | 67.6% |
What is it?
CliffCompaction shrinks a coding agent's conversation history the moment it crosses a token threshold, so a long run stays inside its budget. The technique comes from Carnegie Mellon University and the Bosch Center for AI, and ships as a transparent API proxy under an MIT licence. The agent sits behind the proxy unchanged and never sees that anything was cut.
How does it work?
The proxy only truncates or drops content — it never rephrases or rewrites it. System prompts, task descriptions and the most recent turn pairs are passed through verbatim; tool results under 500 characters are kept whole, while longer ones are dropped because the files they came from are still readable on disk. Agent reasoning is cut to 300 characters and each tool call to its first 150, which keeps the tool name and target path. When the threshold is crossed again, CliffCompaction throws away the previous compacted history and compresses the live session from scratch, so a summary is never summarised twice.
Why does it matter?
Long agent runs get expensive because every turn re-sends the whole history. Trimming that history by fidelity rules instead of re-summarising saves up to 50% of the cost on Terminal-Bench 2.0 while the score goes up rather than down, and holds Kimi K2.6 at 73.27% on SWE-bench Verified with the threshold set to 32K tokens against 73.87% at full context. A team already running Claude Code or Codex CLI on multi-hour jobs can put CliffCompaction in front of its existing setup and change nothing else.
Who is it for?
teams running long coding-agent jobs
Frequently asked questions
- How much does CliffCompaction cost?
- CliffCompaction is free and open source under the MIT licence, published as the cliffcompaction package on PyPI and as a repository on GitHub. There is no paid tier. The saving it targets is the model bill instead: the paper reports up to 50% lower cost on Terminal-Bench 2.0 at the same or better score, because a trimmed history means fewer tokens are re-sent on every turn.
- How is CliffCompaction different from the auto-compaction already in Claude Code?
- CliffCompaction never rewrites text. Harnesses such as Claude Code and Codex CLI fold earlier context into fresh prose, and a summary of a summary can drift away from what really happened. CliffCompaction only truncates or drops, and each time it runs it discards the previous compacted history and starts from the live session — what the authors call never compacting a compaction.
- Can I see what CliffCompaction would cut before it changes anything?
- Yes. CliffCompaction ships a shadow mode, run as cliff run --shadow -- claude, which reports what the proxy would compact while leaving the real requests untouched. The default threshold is 200,000 tokens and can be lowered; the paper measures 45K, 32K, 16K and 8K, plus 128K for longer continual-learning runs.
- Which models did the CliffCompaction paper test?
- The CliffCompaction paper reports SWE-bench Verified and Terminal-Bench 2.0 results for Kimi K2.6, Kimi K2.5, GLM 5.1 and GLM 5 Turbo. On KernelBench Level 3 it reports Kimi K2.7 reaching a 2.23x CUDA kernel speedup after 200 steps and 3.58x after 400 steps, which the authors note beats specialised search algorithms despite CliffCompaction being general purpose.
Try it
uv tool install cliffcompaction && cliff enable