Headroom is an open-source tool that compresses all data sent to AI agents and LLMs—including prompts, tool outputs, logs, RAG chunks, and conversation history—before transmission, reducing token usage by up to 57% in benchmarks like SRE incident debugging while maintaining accuracy. The system employs a local proxy or library integration (Python/TypeScript) using a pipeline of compressors: SmartCrusher for JSON, CodeCompressor for AST-aware code (Python, JS/TS, Go, etc.), and Kompress-v2-base for prose, with CacheAligner preserving provider KV-cache prefixes. Compression is reversible (CCR) via local caching, enabling on-demand retrieval of originals. Output tokens are reduced by appending "be terse" to system prompts and routing reasoning effort (via OpenAI/Anthropic API parameters). Benchmarks show 21% savings for code search, 42% for codebase exploration, and 30% for GitHub triage, with latency under 1.5ms for 100K tokens. Features include cross-agent shared memory, failure learning (mining sessions to auto-generate corrections to CLAUDE.local.md/AGENTS.md), and support for frameworks like LangChain, Strands, and MCP clients. Installation options include pip, uv, npm, and Docker, with enterprise tiers offering model routing and prompt injection detection.

Read original