Headroom is an open-source project maintained by headroomlabs-ai. Its core purpose is to compress content before it is read by an AI agent and enters the LLM, thereby reducing token consumption. It can handle tool output, logs, RAG chunks, files, and conversation history. The official documentation states that its compression is performed on the local machine, and the compression process does not send prompts or file contents anywhere.
Main Capabilities
Headroom provides multiple usage forms:
- Library: Call it directly in Python or TypeScript,
compress(messages), and it can be integrated inline into any application. - Proxy: Start it via
headroom proxy --port 8787, with no code changes required, and it supports any language. - Agent wrap: Wrap an agent with a single command via
headroom wrap claude|codex|grok|copilot|cursor|aider|opencode|cline|continue|goose|openhands|openclaw|vibe|omp|zcode, and undo withheadroom unwrap <tool>. - MCP server: Provides
headroom_compress、headroom_retrieve、headroom_stats, for use by any MCP client. - Cross-agent memory: Share one store among Claude, Codex, Gemini, and Grok, with automatic deduplication.
- headroom learn: Mine failed sessions and write corrections to
CLAUDE.local.md(default, gitignored),CLAUDE.md、AGENTS.md、GEMINI.md, orGROK.md. - Output token reduction: Not only compresses what is sent, but also reduces what the model writes back.
- Reversible compression (CCR): Original content is cached locally and retrieved on demand.
Technical Components
- ContentRouter: Detects the content type and selects the appropriate compressor for it.
- SmartCrusher: Handles general JSON, including arrays of dictionaries, nested objects, and mixed types. It preserves error items, values outside the normal statistical range, and the first and last boundaries, with selection based on field variance statistics rather than keyword lists.
- CodeCompressor: AST-aware compression for Python, JS/TS, Go, Rust, Java, C/C++, C#, and PHP.
- Kompress-v2-base: A HuggingFace model trained on agentic traces.
- CacheAligner: Marks volatile content that would break the provider KV-cache prefix, and never rewrites prompts.
- CCR: Reversible compression, allowing the model to retrieve the original text on demand.
- SharedContext: Passes compressed context between multi-agent workflows.
- Image compression: Achieves 40–90% reduction via a trained ML router.
- Live-zone compression: Compresses only newly added bytes (new tool output, latest turns), while the frozen prefix remains unchanged to preserve the provider cache; history is not discarded.
Usage
The official quick start (60 seconds) includes inline calling in Python. The CLI is released only with the PyPI package; headroom-ai on npm is the TypeScript SDK, imported as a library (import { compress } from 'headroom-ai'), and does not provide the headroom command.
headroom wrap starts the local proxy, installs Serena for semantic code navigation, and starts an agent configured to route through Headroom. For Claude Code, Serena is registered only to the wrapped project (as a local ~/.claude.json in -scope MCP server). You can use --code-memory-scope user to make it available across all projects, or use --code-memory none to skip.
For installation, the official recommendation is to use uv tool installfor the CLI, so that the command is located in an isolated application environment; on macOS, if the default python3 is newer, you can pass --python 3.13. Native wheels currently cover macOS Apple Silicon and Linux; Intel macOS requires the Docker native installation. Python 3.10+ is required.
When to Use
The official guidance on suitability: it is suitable if you run coding agents every day and want to save tokens without changing code, share one memory across multiple agents, or need reversible compression (the original text can be retrieved via CCR within the configured TTL). It is not suitable if you only use a single provider's native compression and do not need cross-agent memory, or if you are in a sandbox where you cannot run local processes.
Headroom is clearly effective in long agent sessions with heavy tool output; for short conversations, prose, and already dense payloads the benefit is small or nonexistent, and blocks below min_input_words are returned as-is.
Limitations and Notes
- The savings ratio depends on how repetitive the payload is: repetitive JSON arrays and log lines can exceed 90% in
benchmarks/bench_latency.py, while prose and already dense output compress very little. - Compression time is negligible: a 10K-token JSON search result has a p50 of 0.21 ms, and at 100K tokens it is 1.4 ms.
- Output savings are a counterfactual estimate; Headroom provides an estimate with a confidence interval and clearly labels it as an estimate.
- In cache mode (the default), the proxy does not re-read the learned conciseness level, so as not to break the prompt cache.
- Regarding Copilot support: macOS Keychain authentication reuse and Windows device authentication have been tested in practice; Linux Secret Service / secret-tool reuse has been implemented but not yet verified on a real desktop; in Docker and CI, an explicit
GITHUB_COPILOT_TOKENorGITHUB_COPILOT_GITHUB_TOKENshould be passed in. - On x86/x86_64, the features supported by ONNX (Magika content detection, embedding relevance) require AVX2; hosts without AVX2 fall back to non-ONNX paths (BM25 relevance, heuristic detection). arm64 and Apple Silicon do not require AVX2.
[all]covers the core stack but does not include framework adapters, which must be installed separately.
For more details (architecture, CCR, model card, full list of limitations), see the project documentation.