Why your token bill is mostly repetition
A coding agent does not send your question. It sends your question plus every tool schema it exposes, plus the whole conversation so far, plus every file it has read this session. That prefix is rebuilt and re-sent on every single turn, so a twenty turn session pays for the same file read twenty times.
This is why the bill grows faster than the work does. The fix is not a smaller model or a shorter prompt. It is compressing the material before it leaves your machine.
The tool this is built on
headroom, from headroomlabs-ai, is an open source compression layer for AI agents. Apache 2.0, 66,006 stars, and it runs locally so your code never leaves your machine. Its own published measurements on real agent workloads:
- Code search over 100 results: 17,765 tokens becomes 1,408. A 92 percent cut.
- SRE incident debugging: 65,694 becomes 5,118. Also 92 percent.
- GitHub issue triage: 54,174 becomes 14,761. A 73 percent cut.
- Codebase exploration: 78,502 becomes 41,254. A 47 percent cut.
Read those numbers carefully, because the spread is the whole lesson. Structured, repetitive material compresses enormously. Dense original prose does not. Where your own savings land depends entirely on what your agent spends its context on.
The number the videos get wrong
You will see 60 to 95 percent quoted everywhere. That figure is real, and it is measured on JSON data. For general coding agent traffic the same project publishes 15 to 20 percent. Both numbers are true and they measure different things.
If a claim does not name the workload it was measured on, it is not a number you can plan with
So the honest expectation is this: enormous savings on tool output, logs, search results and JSON. Modest savings on a session that is mostly you and the model writing new prose. Most real sessions are a mix, which is why the measured end to end figures land between the two.
Does compressing the context make the answers worse
This is the question that actually matters, and it is testable rather than arguable. The published benchmark deltas:
- GSM8K, 100 items: 0.870 baseline against 0.870 compressed. A delta of exactly zero.
- TruthfulQA, 100 items: 0.530 baseline against 0.560 compressed. Slightly better, which is noise at that sample size, not an improvement to believe in.
- SQuAD v2 question answering: 97 percent retained at 19 percent compression.
- BFCL tool calling: 97 percent retained at 32 percent compression.
The reason accuracy holds is worth understanding, because it tells you when it will not. Compression removes redundancy the model was never using: repeated schemas, log preamble, whitespace, boilerplate that appears in every tool result. It is not summarising your reasoning. Push the ratio far enough and you will eventually cut something load bearing, which is why the aggressive numbers appear on JSON and never on prose.
The four ways to run it
- As a proxy. Start it, point your agent at it with a base URL, change nothing else. This is the zero risk way to try it and the way to start.
- As a library. Call compress on your messages inline in Python or TypeScript when you want control over exactly what gets touched.
- As an agent wrap. One command wraps a specific tool, and one command undoes it. Documented targets include Claude Code, Codex, Copilot, Cursor, Cline, Aider, Continue, Goose and OpenHands.
- As an MCP server. Exposes compress, retrieve and stats to any MCP client, so an agent can compress on demand rather than always.
The part nobody mentions
Reversibility is the feature that makes this safe to run in production, and it is the one nobody talks about. Compressed segments are tagged with a reference id and the exact original bytes are cached locally. When the model needs the real thing it calls retrieve and gets it back byte for byte.
That inverts the risk. Without it you are making a permanent bet that the compressor did not throw away something important. With it, the worst case is one extra round trip. Any compression layer you evaluate should be judged on this first: if it cannot hand back the original on demand, it is not compression, it is deletion.
Free, for your email
Get the full setup steps + the copy-paste setup prompt
The rest of this guide (2 more sections) opens right here. The setup prompt, one paste into Claude that sets it all up, comes by email only. Use your real address.
Unlocks: How to evaluate it on your own work in one afternoon · When not to bother
50,000+ follow where these guides come from. No spam, reply “unsubscribe” any time.