AI Coding Agents
Headroom Context Compression Review
Headroom compresses logs, tool results, and other agent input before it reaches the model, and can retain originals for on-demand retrieval. It is worth testing on repetitive payloads, where input savings can be substantial. Compare provider charges per accepted task, since recovery calls and longer sessions can offset smaller requests.
At a glance
| Question | Answer |
|---|---|
| What is it? | A compressor for logs, structured results, and other agent input. |
| What cost does it target? | Input from large payloads, including results carried forward into later requests. |
| Where does it act? | In a Python application’s message list, in a local proxy or agent wrapper, or through MCP tools. |
| How do you try it? | Use uv for the CLI and wrapper, or install the Python library with pip. |
| Can you recover originals? | CCR can store originals locally for headroom_retrieve while the configured retention period allows. |
| What affects savings? | Provider cache charges, recovery calls, and the number of turns all affect cost per accepted task. |
| When is it a good fit? | Large, repetitive results where the agent may still need omitted details. |
| When should you skip it? | Skip the proxy if most messages are short or the client must connect directly to an approved endpoint. |
Where Headroom changes input cost
A coding agent can pull a large search result or log into context and carry it through several model requests. Headroom can shrink that result before the provider sees it. If the compact result stays in later requests, the difference can show up in more than the initial input count. The amount that saves depends on which tokens the provider bills as fresh input, cache writes, or cache reads.
The integration determines where the change happens. A Python application can call the library on its assembled message list. A coding client can use a local proxy between the agent and the provider. The wrapper launches a supported agent with proxy routing configured for that session. An MCP client can expose compression and retrieval as tools. For an MCP trial, confirm that the agent actually calls those tools on the payloads you want to shrink. Merely seeing a registered server in the client tells you little about its effect on input.
How the compressor chooses what to keep
Headroom routes content by type. The README describes SmartCrusher as a JSON compressor that keeps features such as error entries, unusual values, and boundary records. CodeCompressor uses syntax structure for supported source languages. Kompress handles text with an optional model dependency. In the Python library’s default configuration, tool and assistant messages are eligible, and user messages are left intact. The proxy also has a separately enabled output steering feature. Leave that off when the trial is about input compression.
Consider a test system that returns a long array of similar records with an exceptional failure late in the result. The compressed version can give the model enough evidence to find the failure while leaving out routine records. If the task changes to accounting for every record, those omitted records become relevant. Headroom’s CCR mechanism can store the original locally. The model can then call headroom_retrieve to request the underlying content while it remains available under the configured retention time. For a decision that depends on completeness, require the agent to obtain the original and reconcile the result against it. Headroom repository
Install a wrapper and verify the request path
The README shows an isolated CLI install with uv and a Claude Code wrapper. Start with a disposable project and a task whose uncompressed output you can check. Use the health check and confirm with the proxy dashboard that traffic actually flowed through it.
uv tool install --python 3.13 "headroom-ai[all]"
headroom wrap claude
headroom doctor
headroom dashboard
For a client you configure yourself, the README documents a standalone proxy. For an MCP client, it documents a registration command. Run the entry point that matches the integration you want to measure.
headroom proxy --port 8787
headroom mcp install
The Python package also supports an in-process library install. The npm package is a TypeScript SDK and the README pairs it with a running proxy.
pip install headroom-ai
npm install headroom-ai
Record the provider endpoint and agent configuration before wrapping. The README warns that OpenAI-compatible traffic defaults to OpenAI upstream unless you specify the third-party upstream. Confirm the endpoint before sending a request with that provider’s key. Close the session to stop its session-scoped proxy. For durable wrapping, the README documents the unwrap subcommand, which takes the name of the wrapped client. Remove any separate MCP registration or manually configured endpoint from the client where you added it. Start a fresh session and verify that it reaches the original provider directly. Headroom setup and compatibility
What the payload tests and the pilot show
Headroom’s README claims a range of results from its seeded scenarios. Code search fell from 17,199 to 13,597 input tokens, a reported 21% reduction. The incident debugging scenario fell from 55,957 to 24,340, a reported 57%. The project also claims reductions above 90% for repeated JSON arrays and log lines, with little savings on dense prose. Those figures describe particular inputs and settings. A session that mostly reads compact documentation may offer very little for those transforms to remove. Headroom benchmark examples
In tokbench’s independent pilot with N=1 per arm, Headroom v0.23.0 removed 342K input tokens from the requests on its own run path. The benchmark authors reconciled the proxy ledger against provider usage. The wrapped run still billed 3.24M input tokens versus 2.28M for the native run, with 237 turns versus 180. Both completed the same bug-fix task, and the harness already isolated context by phase. More turns mean more opportunities to carry history forward. The pilot records distinct run paths, so it leaves open how often Headroom would change turn count or total cost on that workload. The measured provider path had no prompt-cache discount. tokbench
The latest release at the time of review was v0.45.0. The pilot, with N=1 per arm, prompted a vendor review request about the forge and Pi proxy setup, which can differ from the Claude Code wrapper or library in routing, request history, and tool coverage. An open issue title reports a separate preliminary Claude Code result of 12% lower cost with the pass rate unchanged. The evidence includes only the title. Keep your own integration and settings fixed across tasks. Headroom vendor review request Preliminary Claude Code measurement
Price cache reads and recovery calls separately
The README describes a live zone for compressing new content while retaining a byte-identical frozen prefix. That design aims to preserve provider cache reuse. Measure the cache buckets anyway, especially when adding memory or changing configuration. A drop in total input can coexist with a rise in fresh input if the changed request misses a cache entry. Likewise, fetching an original may enlarge the next prompt and require the model to process the original alongside the previous summary. Prompt caching prices
For an estimate, take the project’s incident example and assume the entire payload is fresh input to Claude Sonnet. The formula is (original tokens − compressed tokens) × input rate ÷ tokens per million. At $2 per million, (55,957 − 24,340) × $2 per million comes to roughly six cents of avoided fresh input. At the $0.10 cache-read rate, removing the same token difference from an otherwise billable cache read saves less than a cent. Both calculations cover a single request and assume the rest of the prompt, output, and cache status stay fixed. Compare actual request charges across the task, including any retrieval. Provider pricing index
What to reproduce from the issue tracker
An open Codex issue describes recovered CCR JSON being offloaded again via the agent’s wrapper. Include a retrieval round trip with a known omitted record in your Codex smoke test, and inspect the tool response the model ultimately receives. CCR recovery report
An open issue reports compression-executor threads pinning CPU cores, and another reports Copilot traffic bypassing the proxy despite successful setup. Check local resource use during sustained traffic and observe live request routing independently of the setup message. The issue titles establish the reported symptoms. Treat your exact client, version, and workload as the test conditions. Executor thread report Copilot routing report
Who should run it and how to measure a trial
Try Headroom when your traces show large, repetitive results entering model requests, particularly if you need details to remain recoverable. Start with the library if your application assembles its own messages and you can exercise compression against fixtures. Try a wrapped session if you use a supported agent and want to test without modifying application code. Skip the proxy trial if your traffic is mostly short messages or your environment requires the client to use a direct approved endpoint. When a task requires exhaustive evidence, compare the compressed workflow against an explicit full-read baseline.
- Pick repeatable tasks that cover large logs, structured output, and dense text. Predefine which facts and checks must survive.
- Run native and wrapped sessions from identical starting states with the same model, provider, task prompt, and cache policy. Repeat each condition to see how much the agent’s path varies.
- Confirm that compression ran, then inspect the provider’s input, cache, and output usage. Record turns, retrieval volume, latency, and the outcome of the acceptance checks.
- Compare cost per accepted task, including failed attempts. Keep the setup only if the savings survive recovery calls and the agent still produces results that pass review. How to measure coding agent token savings
Alternatives for different tool traffic
If Git, searches, and test commands generate most of the noise, RTK filters supported shell commands at execution time. If the agent needs selective search over bulky command output, context-mode indexes results so it can fetch relevant chunks. Pick the candidate that reaches the expensive payloads in your baseline traces and trial it by itself before combining tools. RTK review context-mode review
Sources
- Headroom repository and README (GitHub, accessed 2026-11-30)
- tokbench independent middleware pilot (GitHub, accessed 2026-11-30)
- CCR retrieval re-offload report (GitHub, accessed 2026-11-30)
- Compression-executor thread report (GitHub, accessed 2026-11-30)
- Copilot proxy routing report (GitHub, accessed 2026-11-30)
How this note was produced
Drafted with AI assistance from committed ByteCosts pricing snapshots and deterministic cost formulas. Figures are grounded in the linked sources (last updated 2026-11-30). Read our editorial & automation policy, inspect the methodology, or report a discrepancy.
Headroom Context Compression Review. ByteCosts. Updated 2026-11-30. https://bytecosts.com/blog/headroom-context-compression-review/