Headroom

Keeps giant logs and JSON out of your agent's context window without losing the line that matters

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

Category
Libraries & frameworks
Audience
Developers
Language
Python
Licence
Apache-2.0

Updated

Headroom is a context compression layer for AI agents: a library, an HTTP proxy and an MCP server that shrink tool outputs, logs, whole files and retrieval chunks before they reach the model. It is aimed at developers who run coding agents such as Claude Code, Cursor or Codex and keep watching a single log dump or one JSON blob swallow the entire context window. The project is Apache-2.0 licensed, written mostly in Python with an npm package alongside the PyPI one, and has collected roughly 76,000 stars and 5,900 forks since it first appeared in January 2026.

What it does

Headroom works on the input side of the agent loop. It does not touch what the model writes, only what the model reads. Anything that arrives as bulk text is a target: shell and test output, server logs, JSON API responses, files the agent opens, chunks a RAG pipeline pulled back.

Every headline number here comes from the project itself, not from an independent measurement. The repository claims about 20 percent fewer tokens for coding agents and 60 to 95 percent fewer for JSON, with the same answers. Its own demo compresses 10,144 tokens down to 1,260. The hero image in the README shows a 55,957 token agent prompt going out as 24,340 tokens sent, with the one line that mattered, a FATAL entry at item 67, preserved byte for byte.

It ships in three shapes so it can be inserted at whichever layer you control: import it as a library, route your agent through it as a proxy, or attach it as an MCP server so tool results come back already compressed. The channel's own write-up notes that a single command wraps Claude Code, Cursor or Codex; the saved README is cut off before that command appears, so take the exact invocation from the project's quickstart rather than guessing at it.

How it works

The mechanism is interception. In library form you hand it a string and pass on what it gives back. As a proxy it sits between the agent and the model endpoint, so the agent needs no code changes. As an MCP server it becomes one more tool server in the agent's list and compresses the payloads flowing through it.

The README badges a model called kompress-v2-base published on Hugging Face, which points at a trained compressor rather than plain regex trimming, but the saved copy of the README stops before the pipeline is described, so exactly what gets dropped is not something this page can state. What the project does advertise is selective fidelity: lossy on the bulk, exact on the lines it judges critical, which is the point its demo screenshot is built around.

Getting started

Compression runs locally, on your own machine or your own server. The saved README does not list an operating system, a chip, a memory or VRAM floor, so treat hardware requirements as undocumented rather than assuming it runs anywhere. There is no build to hunt down and no Releases page to visit: the packages are published as headroom-ai on PyPI and headroom-ai on npm, and the quickstart and docs live at docs.headroomlabs.ai.

On money, be clear about what is free. The code is free and self-hosted under Apache-2.0, but Headroom is not a way to stop paying for a model. You still need a paid API key, or your own local model, for the intelligence; Headroom only reduces how many tokens you send, and the price per token is unchanged. The README's navigation also links a section called "Headroom for Teams", which suggests a commercial tier, though the saved copy is cut before it says what that includes or costs.

When to use it / when not

The main catch: you are putting an extra, lossy transformation between your agent and the model, so when an answer comes back wrong you now have two places to look instead of one.

  • Use it instead of asking Claude to summarise the file first, or instead of simply buying a larger context budget, when the bulk of your prompt is machine output: logs, JSON, test runs, retrieved chunks.
  • Don't use it if the model genuinely needs every byte, as in audit trails, forensics or exact diffs, or if your prompts are already small, where the saving will not pay for the extra moving part.
  • Treat the published percentages as the authors' own claims until you have watched your own traffic; token counts are easy to check against your provider's usage dashboard.

Anyone who maintains an agent that reads large machine output should look at this seriously, because it attacks the cost and the quality problem at the same point: a smaller prompt is both cheaper and easier for the model to reason over. The honest framing is that Headroom is plumbing, not a product you interact with, and its value depends entirely on how much junk your agent currently reads. If your context is mostly hand-written prompts, skip it. If your context is mostly logs and JSON, it is the cheapest experiment on the list, and the proxy mode means you can try it without editing your agent at all.

More in Libraries & frameworks

All of Libraries & frameworks →