Headroom
π Description
chopratejas/headroom β compresses everything your AI agent reads before it reaches the LLM: tool outputs, logs, RAG chunks, files, and conversation history. Same answers, a fraction of the tokens. Apache 2.0, ~18k stars and climbing fast in June 2026.
It sits in front of the model as a transparent proxy. Compression is reversible β originals stay local and the model can call headroom_retrieve to pull full context when it actually needs it, so quality isnβt degraded.
The pitch that lands for me: on heavy Claude Code / Cursor / Codex sessions it can stretch your quota far enough to keep working more than an hour before hitting limits β directly addressing the same pain as Token Optimization for Claude Code and Caveman, but on the input/context side.
π§© Features
- Wraps any agent harness β
headroom wrap claudelaunches Claude Code with Headroom intercepting context in front of the model; also Cursor / Codex / Copilot. - Three delivery modes β Python library, transparent proxy, or MCP server.
- Smart compressors β AST-aware code compression, JSON (SmartCrusher), and text (ModernBERT-based); 70β95% reduction on boilerplate.
- Measured savings (from the video): code search 17kβ1.4k tokens (92%), incident debugging 65kβ5k (92%), GitHub issue tracking 54kβ14k (73%), codebase exploration 78kβ41k (47%).
- Quality preserved β benchmarked on GSM8K, TruthfulQA, SQuAD v2, BFCL with near-perfect retention.
headroom perfβ per-model breakdown of tokens saved, cache performance, optimization overhead.headroom learnβ mines failed sessions and writes corrections toCLAUDE.md/AGENTS.md/GEMINI.md.- Output token reduction (
HEADROOM_OUTPUT_SHAPER=1) β trims what the model writes back, not just what you send (output costs ~5Γ input on Opus-class). Two levers from the proxy, no code changes: verbosity steering (appends a βbe terse, donβt restate contextβ note to the system prompt so the cache still hits) and effort routing (dials thinking effort down when a turn is just resuming after a tool result, keeps full effort on new questions/errors).headroom learn --verbosityinfers your preferred terseness from past sessions. - Cross-agent memory β shared store across Claude Code / Codex / Gemini with agent provenance and auto-dedup;
SharedContextpasses compressed context across multi-agent workflows. - CCR (reversible) β the named mechanism behind reversibility: originals cached locally, model calls
headroom_retrievewithin TTL. - Copilot CLI subscription mode β
headroom wrap copilot --subscriptionroutes GitHub Copilot CLI subscription traffic through the local proxy, exchanging a Headroom-specific OAuth token for Copilotβs short-lived API token.
π Compared to
Headroomβs pitch vs. neighbours: it runs locally, covers all content (tools, RAG, logs, files, history), works across frameworks, and is reversible β where RTK (shell-output only) and lean-ctx (CLI/MCP) are local but not reversible, hosted APIs (Compresr, Token Co.) are neither local nor reversible, and OpenAI Compaction is provider-native conversation history only. Headroom actually ships the RTK binary and can use lean-ctx as its CLI context tool (HEADROOM_CONTEXT_TOOL=lean-ctx).
Reasoning for
The input-side complement to Caveman (which shrinks output tokens). Together they attack both halves of the bill. Fits squarely in the Context Engineering / Progressive Disclosure toolkit β instead of curating what the agent fetches, Headroom compresses whatever it does fetch, transparently. Worth trialing on Qamera AI / PLSoft agent work where long codebase-exploration loops burn quota.
β οΈ Caveats
- Installs Serena by default (unrelated MCP) β pass
--no-saduring install to skip it. - Telemetry on by default β disable it; the code is open source so you can audit/strip it.
π Links
- Repo: https://github.com/chopratejas/headroom (Apache 2.0)
- Install:
pip install "headroom-ai[all]"thenheadroom wrap claude --no-sa
π Related notes
- Caveman β output-token compression; the natural pairing
- Token Optimization for Claude Code β broader catalog of token-reduction tools
- Context Engineering Β· Progressive Disclosure β the design context Headroom plugs into
- Claude Code β primary host harness
- Surfaced in Open-Source AI Projects Roundup (Matthew Berman)
Template: tool