Headroom shrinks tool outputs, logs, JSON, and chat history before LLM calls to cut input tokens while preserving retrievable originals. It offers a Python library, proxy, MCP tools, and agent wrappers.
Overview
Headroom intercepts bulky agent payloads—search results, API JSON, build logs, RAG chunks, and file reads—and compresses them on the user’s machine before they reach the model. Documented benchmarks report substantial token reductions on repetitive structured data and moderate savings on realistic agent scenarios, with compression latency measured in sub-millisecond to low-millisecond ranges for large JSON.
A compress function works in-process in Python and TypeScript. A local proxy rewrites traffic for OpenAI-compatible and Anthropic endpoints with no application code changes. The headroom wrap command launches supported coding agents through that proxy; headroom unwrap restores prior configuration. MCP tools expose compress, retrieve, and stats operations, and compress-cache-retrieve storage lets models fetch full originals when needed.
Content routing picks compressors for JSON, code, prose, and logs. Optional features include cross-agent memory, failure learning into project instruction files, cache-aware prefix handling, and output verbosity shaping on supported APIs. Install paths include PyPI, npm for the TypeScript SDK, and persistent proxy deployment commands.
Key features
- In-process message compression
- Local OpenAI-compatible proxy
- Agent wrap for major CLIs
- MCP compress and retrieve tools
- Reversible compress-cache-retrieve store
- Smart JSON and log crushing
- Cross-agent shared memory
- Framework integrations for LangChain and others
Use cases
- Reducing agent tool output tokens
- Proxying Claude Code or Codex sessions
- Compressing RAG chunks before chat
- Cutting JSON API context size