Headroom: Open-Source Tool Compresses AI Agent Context by Up to 95%
Headroom is an open-source library that compresses AI agent tool outputs by 55-95%, losslessly, via proxy or library mode. 59K GitHub stars.
Headroom is an open-source compression layer that sits between AI agents and LLMs, intercepting tool outputs — search results, git logs, JSON responses, file contents — before they reach the model. With over 59,000 GitHub stars, the project reports community-wide savings of 41.8 billion tokens and roughly $176,600 in inference costs to date.
In an independent test, a 500-entry JSON payload (~18,500 tokens) was compressed to about 8,300 tokens, a 55% reduction, without losing information — originals are retained and retrievable through a dedicated tool. Under the hood, Headroom auto-detects content type using Google's Magika, then routes data to specialized compressors: a statistical engine for JSON, an AST-aware compressor for code, and a HuggingFace model for prose.
The tool addresses a real bottleneck in agentic workflows, where a large share of an LLM's context budget is consumed simply loading raw tool output rather than reasoning about it. It ships as a zero-config HTTP proxy or a one-line Python/TypeScript library call, plus an MCP server for compatible clients. Limitations include negligible gains on small payloads under ~1,000 characters and a heavy dependency footprint when installing full ML-based compressors.