Skip to content

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

docs(readme): rebuild the README on the Headroom brand (#3392)

Tejas Chopra7c4d696cf92c
diff --git a/.github/assets/hero.svg b/.github/assets/hero.svg
new file mode 100644
index 000000000..3f170e2e8
--- /dev/null
+++ b/.github/assets/hero.svg
@@ -0,0 +1,104 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 880 356" width="880" height="356" role="img"
+ aria-label="Headroom — the context compression layer for AI agents. A 55,957 token agent prompt is compressed to the 24,340 tokens actually sent to the model: 31,617 removed, 57 percent fewer input tokens. The FATAL log line at item 67 survives byte for byte.">
+ <title>Headroom — 55,957 tokens in, 24,340 sent, 57% fewer input tokens</title>
+
+ <defs>
+ <!-- headroomlabs.ai/brand
+ Headroom Mint #00F0B5 primary accent
+ Obsidian Space #070A0F background
+ Midnight Panel #0C1118 surfaces
+ Cyan Glow #65D8FF secondary accent
+ Pure White #FFFFFF primary type
+ Slate Muted #98A4B3 secondary type
+ The logomark is reproduced at its published geometry and colour. Brand
+ guidance is to place it on dark, so this hero is dark in both GitHub
+ themes rather than recoloured for a light one. -->
+
+ <pattern id="grid" width="44" height="44" patternUnits="userSpaceOnUse">
+ <path d="M44 0H0V44" fill="none" stroke="#00F0B5" stroke-opacity="0.05" stroke-width="1"/>
+ </pattern>
+
+ <radialGradient id="glow" cx="50%" cy="18%" r="72%">
+ <stop offset="0%" stop-color="#00F0B5" stop-opacity="0.14"/>
+ <stop offset="100%" stop-color="#00F0B5" stop-opacity="0"/>
+ </radialGradient>
+
+ <linearGradient id="sent" gradientUnits="userSpaceOnUse" x1="60" y1="0" x2="390" y2="0">
+ <stop offset="0%" stop-color="#00F0B5"/>
+ <stop offset="100%" stop-color="#0FD9AE"/>
+ </linearGradient>
+
+ <linearGradient id="sweep" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="130" y2="0">
+ <stop offset="0%" stop-color="#65D8FF" stop-opacity="0"/>
+ <stop offset="50%" stop-color="#65D8FF" stop-opacity="0.55"/>
+ <stop offset="100%" stop-color="#65D8FF" stop-opacity="0"/>
+ </linearGradient>
+
+ <clipPath id="clipSent"><rect x="60" y="230" width="330" height="34" rx="6"/></clipPath>
+
+ <style>
+ .s { font-family: "Segoe UI", Inter, -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif; }
+ .m { font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; }
+
+ /* The removed span dims and lifts, so the eye reads it as absence. */
+ .removed { animation: fade 4s ease-in-out infinite; }
+ @keyframes fade { 0%, 100% { opacity: 1 } 50% { opacity: .45 } }
+
+ /* Cyan passes over the compressed bar once per cycle. */
+ .sweeper { animation: pass 4s ease-in-out infinite; }
+ @keyframes pass { 0%, 10% { transform: translateX(-140px) } 65%, 100% { transform: translateX(340px) } }
+
+ /* Both markers pulse in step, which is how you read them as one line. */
+ .marker { animation: beat 4s ease-in-out infinite; }
+ @keyframes beat { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }
+
+ @media (prefers-reduced-motion: reduce) {
+ .removed, .sweeper, .marker { animation: none }
+ }
+ </style>
+ </defs>
+
+ <rect width="880" height="356" fill="#070A0F"/>
+ <rect width="880" height="356" fill="url(#grid)"/>
+ <rect width="880" height="230" fill="url(#glow)"/>
+
+ <!-- ── lockup: published logomark geometry, scaled 32→46 ─────────────── -->
+ <g transform="translate(297 35) scale(2.2)" stroke-linecap="square">
+ <path d="M 11 8 L 7 8 L 7 24 L 11 24" fill="none" stroke="#00F0B5" stroke-width="2"/>
+ <path d="M 21 8 L 25 8 L 25 24 L 21 24" fill="none" stroke="#00F0B5" stroke-width="2"/>
+ <rect x="11" y="14" width="10" height="2" fill="#00F0B5"/>
+ <rect x="13" y="18" width="6" height="2" fill="#00F0B5"/>
+ </g>
+ <text x="370" y="86" class="s" font-size="42" font-weight="700" letter-spacing="-0.8" fill="#FFFFFF">Headroom</text>
+
+ <text x="440" y="122" class="s" font-size="14.5" fill="#98A4B3" text-anchor="middle">The context compression layer for AI agents</text>
+
+ <!-- ── what the agent produced ───────────────────────────────────────── -->
+ <text x="60" y="178" class="s" font-size="10.5" fill="#98A4B3" letter-spacing="1.6">CONTEXT IN</text>
+ <text x="820" y="178" class="m" font-size="13" fill="#FFFFFF" text-anchor="end" font-weight="600">55,957 tokens</text>
+
+ <rect x="60" y="188" width="760" height="34" rx="6" fill="#0C1118" stroke="#1B2532"/>
+ <rect x="60" y="188" width="330" height="34" rx="6" fill="#00F0B5" opacity="0.16"/>
+ <g class="removed">
+ <text x="605" y="210" class="s" font-size="13" fill="#98A4B3" text-anchor="middle">31,617 tokens removed</text>
+ </g>
+ <rect class="marker" x="286" y="188" width="4" height="34" fill="#FFFFFF"/>
+
+ <!-- the cut, marked in both bars -->
+ <line x1="390" y1="188" x2="390" y2="264" stroke="#65D8FF" stroke-width="1" stroke-dasharray="3 4" opacity="0.5"/>
+
+ <!-- ── what actually goes to the model ───────────────────────────────── -->
+ <rect x="60" y="230" width="330" height="34" rx="6" fill="url(#sent)"/>
+ <g clip-path="url(#clipSent)">
+ <rect class="sweeper" x="60" y="230" width="130" height="34" fill="url(#sweep)"/>
+ </g>
+ <rect class="marker" x="286" y="230" width="4" height="34" fill="#070A0F"/>
+ <text x="605" y="252" class="s" font-size="13" fill="#00F0B5" text-anchor="middle" font-weight="600">57% fewer input tokens</text>
+
+ <text x="60" y="290" class="s" font-size="10.5" fill="#98A4B3" letter-spacing="1.6">SENT TO MODEL</text>
+ <text x="390" y="290" class="m" font-size="13" fill="#00F0B5" text-anchor="end" font-weight="600">24,340 tokens</text>
+
+ <!-- ── the line that must not be dropped ─────────────────────────────── -->
+ <rect x="60" y="318" width="4" height="11" fill="#FFFFFF"/>
+ <text x="76" y="328" class="m" font-size="11" fill="#98A4B3">the FATAL line at item 67 survives, byte for byte</text>
+</svg>
diff --git a/README.md b/README.md
index e891ac2f0..376a0d28c 100644
--- a/README.md
+++ b/README.md
@@ -1,62 +1,59 @@
-<div align="center"><pre>
- ██╗ ██╗███████╗ █████╗ ██████╗ ██████╗ ██████╗ ██████╗ ███╗ ███╗
- ██║ ██║██╔════╝██╔══██╗██╔══██╗██╔══██╗██╔═══██╗██╔═══██╗████╗ ████║
- ███████║█████╗ ███████║██║ ██║██████╔╝██║ ██║██║ ██║██╔████╔██║
- ██╔══██║██╔══╝ ██╔══██║██║ ██║██╔══██╗██║ ██║██║ ██║██║╚██╔╝██║
- ██║ ██║███████╗██║ ██║██████╔╝██║ ██║╚██████╔╝╚██████╔╝██║ ╚═╝ ██║
- ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝
- The context compression layer for AI agents
-</pre></div>
-
-<p align="center"><strong>60–95% fewer tokens (for JSON data), 15-20% fewer tokens (for coding agents) · library · proxy · MCP · content-aware compressors · local-first · reversible</strong></p>
-
-<p align="center">
+<div align="center">
+
+<img src=".github/assets/hero.svg" alt="Headroom — the context compression layer for AI agents. A 55,957 token agent prompt compresses to the 24,340 tokens actually sent to the model, and the FATAL line at item 67 survives byte for byte." width="880">
+
+<a href="https://trendshift.io/repositories/20881" target="_blank"><img src="https://trendshift.io/api/badge/repositories/20881" alt="headroomlabs-ai/headroom | Trendshift — #1 Repository Of The Day" width="250" height="55"/></a>
+
+<p>
+ <a href="https://github.com/headroomlabs-ai/headroom"><img src="https://img.shields.io/github/stars/headroomlabs-ai/headroom?style=flat&color=00F0B5&labelColor=0C1118&label=stars" alt="GitHub stars"></a>
<a href="https://github.com/headroomlabs-ai/headroom/actions/workflows/ci.yml"><img src="https://github.com/headroomlabs-ai/headroom/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
- <a href="https://app.codecov.io/gh/headroomlabs-ai/headroom"><img src="https://codecov.io/gh/headroomlabs-ai/headroom/graph/badge.svg" alt="codecov"></a>
- <a href="https://pypi.org/project/headroom-ai/"><img src="https://img.shields.io/pypi/v/headroom-ai.svg" alt="PyPI"></a>
- <a href="https://www.npmjs.com/package/headroom-ai"><img src="https://img.shields.io/npm/v/headroom-ai.svg" alt="npm"></a>
- <a href="https://huggingface.co/chopratejas/kompress-v2-base"><img src="https://img.shields.io/badge/model-Kompress--v2--base-yellow.svg" alt="Model: Kompress-v2-base"></a>
- <a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" alt="License: Apache 2.0"></a>
- <a href="https://docs.headroomlabs.ai/docs"><img src="https://img.shields.io/badge/docs-online-blue.svg" alt="Docs"></a>
+ <a href="https://pypi.org/project/headroom-ai/"><img src="https://img.shields.io/pypi/v/headroom-ai.svg?color=00F0B5&labelColor=0C1118&label=pypi" alt="PyPI"></a>
+ <a href="https://www.npmjs.com/package/headroom-ai"><img src="https://img.shields.io/npm/v/headroom-ai.svg?color=00F0B5&labelColor=0C1118&label=npm" alt="npm"></a>
+ <a href="https://huggingface.co/chopratejas/kompress-v2-base"><img src="https://img.shields.io/badge/model-kompress--v2--base-65D8FF?labelColor=0C1118" alt="Model"></a>
+ <a href="https://docs.headroomlabs.ai/docs"><img src="https://img.shields.io/badge/docs-online-00F0B5?labelColor=0C1118" alt="Docs"></a>
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-98A4B3?labelColor=0C1118" alt="License"></a>
</p>
-<!-- mcp-name: io.github.headroomlabs-ai/headroom -->
-
-<p align="center">
- <a href="https://docs.headroomlabs.ai/docs">Docs</a> ·
+<p>
+ <b><a href="https://docs.headroomlabs.ai/docs/quickstart">Quickstart</a></b> ·
<a href="#get-started-60-seconds">Install</a> ·
<a href="#proof">Proof</a> ·
- <a href="#agent-compatibility-matrix">Agents</a> ·
+ <a href="#agent-compatibility">Agents</a> ·
+ <a href="https://docs.headroomlabs.ai/docs">Docs</a> ·
<a href="https://discord.gg/yRmaUNpsPJ">Discord</a> ·
<a href="llms.txt">llms.txt</a>
</p>
-<p align="center"><sub>
- <b>AI agents / LLMs:</b> read <a href="llms.txt"><code>/llms.txt</code></a> here, or fetch <a href="https://docs.headroomlabs.ai/llms.txt">the live index</a> / <a href="https://docs.headroomlabs.ai/llms-full.txt">full docs blob</a>.
-</sub></p>
+<sub><b>AI agents / LLMs:</b> read <a href="llms.txt"><code>/llms.txt</code></a> here, or fetch
+<a href="https://docs.headroomlabs.ai/llms.txt">the live index</a> ·
+<a href="https://docs.headroomlabs.ai/llms-full.txt">full docs blob</a>.</sub>
----
-<p align="center"><a href="https://trendshift.io/repositories/20881" target="_blank"><img src="https://trendshift.io/api/badge/repositories/20881" alt="chopratejas%2Fheadroom | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a></p>
+</div>
-Headroom compresses everything your AI agent reads — tool outputs, logs, RAG chunks, files, and conversation history — before it reaches the LLM. Same answers, fraction of the tokens.
+<!-- mcp-name: io.github.headroomlabs-ai/headroom -->
-<p align="center">
- <img src="HeadroomDemo-Fast.gif" alt="Headroom in action" width="820">
- <br/><sub>Live: 10,144 → 1,260 tokens — same FATAL found.</sub>
-</p>
+Headroom compresses everything your AI agent reads — tool outputs, logs, RAG
+chunks, files, and conversation history — before it reaches the LLM. Same
+answers, fraction of the tokens. Compression runs on your machine; no prompt or
+file content is sent anywhere to be compressed.
+
+<div align="center">
+ <img src="HeadroomDemo-Fast.gif" alt="Headroom compressing a 10,144 token log dump to 1,260 tokens while preserving the FATAL line" width="820">
+ <br><sub>10,144 → 1,260 tokens. The same <code>FATAL</code> found.</sub>
+</div>
## What it does
-- **Library** — `compress(messages)` in Python or TypeScript, inline in any app
-- **Proxy** — `headroom proxy --port 8787`, zero code changes, any language
-- **Agent wrap** — `headroom wrap claude|codex|grok|copilot|cursor|aider|opencode|cline|continue|goose|openhands|openclaw|vibe|omp|zcode` in one command; undo with `headroom unwrap <tool>`
-- **MCP server** — `headroom_compress`, `headroom_retrieve`, `headroom_stats` for any MCP client
-- **Cross-agent memory** — shared store across Claude, Codex, Gemini, Grok, auto-dedup
-- **`headroom learn`** — mines failed sessions, writes corrections to `CLAUDE.local.md` (default, gitignored) or `CLAUDE.md` / `AGENTS.md` / `GEMINI.md` / `GROK.md`
-- **Output token reduction** — trims what the model *writes back* (not just what you send): drops ceremony/restated code and skips deep "thinking" on routine steps. See [Output token reduction](#output-token-reduction-cut-what-the-model-writes-back).
-- **Reversible (CCR)** — originals are cached for retrieval on demand
+- **Library** — `compress(messages)` in Python or TypeScript, inline in any app.
+- **Proxy** — `headroom proxy --port 8787`, zero code changes, any language.
+- **Agent wrap** — `headroom wrap claude|codex|grok|copilot|cursor|aider|opencode|cline|continue|goose|openhands|openclaw|vibe|omp|zcode` in one command; undo with `headroom unwrap <tool>`.
+- **MCP server** — `headroom_compress`, `headroom_retrieve`, `headroom_stats` for any MCP client.
+- **Cross-agent memory** — one shared store across Claude, Codex, Gemini and Grok, with automatic dedup.
+- **`headroom learn`** — mines failed sessions and writes corrections to `CLAUDE.local.md` (default, gitignored), `CLAUDE.md`, `AGENTS.md`, `GEMINI.md` or `GROK.md`.
+- **Output token reduction** — trims what the model *writes back*, not only what you send. See [below](#output-token-reduction).
+- **Reversible (CCR)** — originals are cached locally and retrieved on demand.
-## How it works (30 seconds)
+## How it works
```
Your agent / app
@@ -78,366 +75,381 @@ Headroom compresses everything your AI agent reads — tool outputs, logs, RAG c
LLM provider (Anthropic · OpenAI · Bedrock · …)
```
-- **ContentRouter** — detects content type, selects the right compressor
-- **SmartCrusher / CodeCompressor / Kompress-v2-base** — compress JSON, AST, or prose
-- **CacheAligner** - detects and warns about volatile content that can bust provider KV cache prefixes; never rewrites prompts
-- **CCR** — stores originals locally; LLM calls `headroom_retrieve` if it needs them
+- **ContentRouter** detects the content type and selects a compressor for it.
+- **SmartCrusher / CodeCompressor / Kompress-v2-base** handle JSON, source code and prose respectively.
+- **CacheAligner** flags volatile content that would bust a provider KV-cache prefix. It never rewrites prompts.
+- **CCR** stores originals locally so the model can call `headroom_retrieve` when it needs the full text.
-→ [Architecture](https://docs.headroomlabs.ai/docs/architecture) · [CCR reversible compression](https://docs.headroomlabs.ai/docs/ccr) · [Kompress-v2-base model card](https://huggingface.co/chopratejas/kompress-v2-base)
+→ [Architecture](https://docs.headroomlabs.ai/docs/architecture) ·
+[CCR](https://docs.headroomlabs.ai/docs/ccr) ·
+[Kompress-v2-base model card](https://huggingface.co/chopratejas/kompress-v2-base)
## Get started (60 seconds)
```bash
# 1 — Install
-uv tool install --python 3.13 "headroom-ai[all]" # CLI as a global tool in a self-contained virtual env
+uv tool install --python 3.13 "headroom-ai[all]" # CLI in a self-contained env
pip install "headroom-ai[all]" # Python — ships the `headroom` CLI
-npm install headroom-ai # TypeScript SDK only — no `headroom` CLI
+npm install headroom-ai # TypeScript SDK only — no CLI
-# 2 — Pick your mode (the `headroom` commands below come from the uv or pip install)
+# 2 — Pick a mode
headroom deploy # turnkey local deployment + agent config
headroom wrap claude # wrap a coding agent
headroom proxy --port 8787 # drop-in proxy, zero code changes
-# or: from headroom import compress # inline library
+# or: from headroom import compress # inline library
-# 3 — Verify setup and see the savings
-headroom doctor # health check — confirms routing is working
+# 3 — Check it and watch the savings
+headroom doctor # health check — confirms routing works
headroom perf
-headroom dashboard # live savings dashboard (proxy must be running)
+headroom dashboard # live savings (proxy must be running)
```
-To use headroom, it is recommended you launch a wrapped agent session each time so that all necessary setup is completed. When wrapping a coding agent, headroom starts a local proxy, installs **Serena** for semantic code navigation, and launches a coding agent session configured to proxy requests through headroom.
+Inline, in Python:
-Serena is registered at **user scope** (for Claude Code, in `~/.claude.json`), so it stays available in your other projects until you run `headroom unwrap`. To skip it entirely, wrap with `--code-memory none`.
+```python
+from headroom import compress
+from openai import OpenAI
-The `headroom` CLI ships **only** via the PyPI package. The npm `headroom-ai` is the TypeScript SDK — a library you import (`import { compress } from 'headroom-ai'`), not a CLI, so it provides no `headroom` command.
+messages = [{"role": "user", "content": "Analyze these results"}]
+result = compress(messages, model="gpt-4o")
-Granular extras: `[proxy]`, `[mcp]`, `[ml]`, `[code]`, `[memory]`, `[vector]` (optional HNSW backend — needs a C++ toolchain, not in `[all]`), `[relevance]`, `[image]`, `[agno]`, `[langchain]`, `[evals]`, `[pytorch-mps]` (Apple-GPU memory-embedder offload — set `HEADROOM_EMBEDDER_RUNTIME=pytorch_mps`). Requires **Python 3.10+**.
+client = OpenAI()
+response = client.chat.completions.create(model="gpt-4o", messages=result.messages)
+print(f"Saved {result.tokens_saved} tokens ({result.compression_ratio:.0%})")
+```
-### Codex / global install
+Launch a wrapped agent session each time, so the setup runs. `headroom wrap`
+starts a local proxy, installs **[Serena](https://github.com/oraios/serena)** for
+semantic code navigation, and launches the agent configured to route through
+Headroom. Serena is registered at user scope (for Claude Code, in
+`~/.claude.json`), so it stays available in your other projects until you run
+`headroom unwrap`. Skip it with `--code-memory none`.
-If Codex or another MCP client cannot inherit a shell `PATH` reliably, install Headroom as a persistent uv tool and point the client at the absolute binary path:
+The `headroom` CLI ships only in the PyPI package. The npm `headroom-ai` package
+is the TypeScript SDK — a library you import
+(`import { compress } from 'headroom-ai'`) — and provides no `headroom` command.
-```bash
-uv tool install "headroom-ai[all]"
-command -v headroom
-```
+## Proof
-Then use the returned path in MCP config:
+Four scenarios built from real MCP server output formats, measured with the
+provider tokenizer and the shipped `compress()`. Seeded and offline, so you get
+the same numbers we did:
-```toml
-[mcp_servers.headroom]
-command = "/absolute/path/from/command-v/headroom"
-args = ["mcp", "serve"]
+```bash
+uv run python benchmarks/index_proof_table.py --seed 20260902
```
-`command = "headroom"` only works when the client starts with a `PATH` that already includes the uv tool directory.
+| Scenario | Before | After | Saved |
+|---|---:|---:|---:|
+| Code search (100 results) | 17,199 | 13,597 | **21%** |
+| SRE incident debugging | 55,957 | 24,340 | **57%** |
+| Codebase exploration | 58,801 | 33,895 | **42%** |
+| GitHub issue triage | 46,067 | 32,429 | **30%** |
-## Proof
-
-**Savings on real agent workloads:**
-
-| Workload | Before | After | Savings |
-|-------------------------------|-------:|-------:|--------:|
-| Code search (100 results) | 17,765 | 1,408 | **92%** |
-| SRE incident debugging | 65,694 | 5,118 | **92%** |
-| GitHub issue triage | 54,174 | 14,761 | **73%** |
-| Codebase exploration | 78,502 | 41,254 | **47%** |
+Savings scale with how repetitive the payload is. Repeated JSON arrays and log
+lines clear 90% in `benchmarks/bench_latency.py`; prose and already-dense output
+compress very little. Run `headroom savings` against your own traffic for the
+number that applies to you.
-**Accuracy preserved on standard benchmarks:**
+Compression costs **well under a millisecond** — 0.21 ms p50 on a 10K-token JSON
+search result, 1.4 ms at 100K tokens — so it does not show up in agent latency.
-| Benchmark | Category | N | Baseline | Headroom | Delta |
-|------------|----------|----:|---------:|---------:|------------|
-| GSM8K | Math | 100 | 0.870 | 0.870 | **±0.000** |
-| TruthfulQA | Factual | 100 | 0.530 | 0.560 | **+0.030** |
-| SQuAD v2 | QA | 100 | — | **97%** | 19% compression |
-| BFCL | Tools | 100 | — | **97%** | 32% compression |
+**Accuracy.** `python -m headroom.evals suite --tier 1`:
-Reproduce: `python -m headroom.evals suite --tier 1` · [Full benchmarks & methodology](https://docs.headroomlabs.ai/docs/benchmarks)
+| Benchmark | Category | N | Baseline | Headroom | Delta |
+|---|---|---:|---:|---:|---|
+| GSM8K | Math | 100 | 0.870 | 0.870 | ±0.000 |
+| TruthfulQA | Factual | 100 | 0.530 | 0.560 | +0.030 |
+| SQuAD v2 | QA | 100 | — | 97% | at 19% compression |
+| BFCL | Tools | 100 | — | 97% | at 32% compression |
-## Output token reduction (cut what the model writes back)
+At N=100 a delta of ±0.03 falls inside the confidence interval, so TruthfulQA
+shows no detectable difference rather than an improvement.
+[Methodology →](https://docs.headroomlabs.ai/docs/benchmarks)
-Everything above shrinks the prompt you **send**. But you also pay for every
-token the model **writes back** — and on Opus-class models output costs 5× input.
-A lot of that output is waste: "Great, let me…" preambles, re-printing code you
-just showed it, and deep "thinking" on routine steps like reading a file.
+## Output token reduction
-Headroom can trim that too, from the proxy, without you changing any code:
+Everything above shrinks the prompt you **send**. You also pay for every token
+the model **writes back**, and on Opus-class models output costs 5× input. Much
+of that output is ceremony: "Great, let me…" preambles, code re-printed straight
+back at you, and deep reasoning spent on routine steps like reading a file.
-- **Verbosity steering** — appends a short "be terse, don't restate context"
- note to the end of the system prompt (so your prompt cache still hits).
-- **Effort routing** — when a turn is just the model resuming after a tool result
- (a file read, a passing test), it dials the model's thinking effort down. New
- questions and errors keep full effort.
+Headroom trims it from the proxy, with no change to your code:
-Applies to Anthropic `/v1/messages` **and** OpenAI-compatible endpoints
-(`/v1/chat/completions`, `/v1/responses`). Effort routing uses
-`reasoning_effort` on OpenAI, `thinking.budget_tokens` /
-`output_config.effort` on Anthropic — same clamp-only invariant on both
-paths, same `output_shaper:*` label vocabulary.
+- **Verbosity steering** appends a short "be terse, don't restate context" note to the *end* of the system prompt, so your prompt cache still hits.
+- **Effort routing** dials thinking effort down when a turn is only the model resuming after a tool result — a file read, a passing test. New questions and errors keep full effort.
-Turn it on:
+Both apply to Anthropic `/v1/messages` and to OpenAI-compatible
+`/v1/chat/completions` and `/v1/responses`. Effort routing uses
+`reasoning_effort` on OpenAI and `thinking.budget_tokens` / `output_config.effort`
+on Anthropic, with the same clamp-only invariant and the same `output_shaper:*`
+labels on both paths.
```bash
export HEADROOM_OUTPUT_SHAPER=1 # off by default
headroom proxy --port 8787
```
-> **Already running a proxy?** These switches are read *live* on every request,
-> so a proxy that `headroom wrap` **reused** (rather than started) would not see
-> a value you export afterwards — its environment was snapshotted at launch.
-> `headroom wrap` now hot-syncs your current settings to the running proxy via a
-> loopback `POST /admin/runtime-env`, so they take effect immediately with **no
-> restart** (no cold start, no dropped requests, no lost caches). Set them before
-> you `wrap`. On a shared proxy these overrides are global — the last explicit
+> **Already running a proxy?** These switches are read live on every request, so
+> a proxy that `headroom wrap` *reused* rather than started would not see a value
+> you export afterwards — its environment was snapshotted at launch. `headroom
+> wrap` hot-syncs your current settings to the running proxy over a loopback
+> `POST /admin/runtime-env`, so they take effect with no restart and no dropped
+> requests. On a shared proxy these overrides are global; the last explicit
> setting wins.
-**Learn the right terseness for you.** People don't *say* how terse they want
-answers — they *show* it (they interrupt long replies, or move on before they
-could have read them). `headroom learn --verbosity` reads your past sessions and
-picks the level automatically:
+**Terseness you didn't have to configure.** People rarely state how terse they
+want answers — they show it, by interrupting long replies or moving on before
+they could have read them. `headroom learn --verbosity` reads past sessions and
+picks the level:
```bash
-headroom learn --verbosity # preview what it found (dry run)
-headroom learn --verbosity --apply # save it; the proxy uses it from now on
+headroom learn --verbosity # dry run — preview what it found
+headroom learn --verbosity --apply # save it; the proxy picks it up
```
-**See how many output tokens you saved.** Output savings are *counterfactual* —
-we never see what the model *would* have written — so Headroom reports an honest
-**estimate with a confidence range**, never a made-up number:
+**Measuring it.** Output savings are counterfactual — we never see what the model
+*would* have written — so Headroom reports an estimate with a confidence range
+and labels it as one:
```bash
headroom output-savings
# Reduction: 31.7% (95% CI 27.7% … 35.7%) [estimated]
```
-Want a *measured* number instead of an estimate? Leave 10% of conversations
-unshaped as a control group: `export HEADROOM_OUTPUT_HOLDOUT=0.1`. The dashboard
-shows an **Output Tokens Saved** card next to input compression, labelled
-`measured` or `estimated` with the confidence band.
-
-→ Full write-up incl. the measurement methodology: [Output token reduction](https://docs.headroomlabs.ai/docs/savings)
-
-<a href="https://www.star-history.com/?repos=chopratejas%2Fheadroom&type=date&legend=top-left">
- <picture>
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=headroomlabs-ai/headroom&type=date&legend=top-left" />
- </picture>
-</a>
-
-## Agent compatibility matrix
-
-| Agent | `headroom wrap` | Notes |
-|--------------|:---------------:|----------------------------------|
-| Claude Code | ✅ | `--memory` · `--code-graph` · `--1m` · `--tool-search` |
-| Codex | ✅ | shares memory with Claude |
-| Grok CLI | ✅ | routes via `GROK_MODELS_BASE_URL` |
-| Cursor | Manual setup | starts proxy and prints base URLs for Cursor settings |
-| Aider | ✅ | starts proxy + launches |
-| Copilot CLI | ✅ | starts proxy + launches |
-| VS Code Copilot | ✅ | transparent proxy; preserves selected model |
-| OpenClaw | ✅ | installs as ContextEngine plugin |
-| OpenCode | ✅ | injects config · starts proxy + launches |
-| Cline | ✅ | starts proxy + injects config |
-| Continue | ✅ | starts proxy + injects config |
-| Goose | ✅ | starts proxy + launches |
-| OpenHands | ✅ | starts proxy + launches |
-| Mistral Vibe | ✅ | starts proxy + launches |
-| Oh My Pi | ✅ | injects config · starts proxy + launches |
-| Cortex Code | Library only | 60–65% savings (library mode; no `wrap`) |
-| Kimi CLI | ✅ | OAuth bearer forwarded — log in once |
-| ZCode | ✅ | starts proxy and prints base URLs for ZCode settings |
-
-Any OpenAI-compatible client works via `headroom proxy`. MCP-native: `headroom mcp install`.
-Undo durable wrapping with `headroom unwrap <tool>` (supports: `claude`, `copilot`, `codex`, `grok`, `kimi`, `omp`, `opencode`, `openclaw`, `zcode`).
-Registry authors can use the canonical [`server.json`](server.json) in the repo root instead of reconstructing the `headroom mcp serve` contract from prose.
-
-### GitHub Copilot CLI subscription mode
-
-Headroom can route GitHub Copilot CLI subscription traffic through the local proxy:
+For a measured number instead, hold out 10% of conversations as an unshaped
+control: `export HEADROOM_OUTPUT_HOLDOUT=0.1`. The dashboard's **Output Tokens
+Saved** card then reads `measured` rather than `estimated`, with the band.
+
+→ [Output token reduction](https://docs.headroomlabs.ai/docs/savings)
+
+## Agent compatibility
+
+| Agent | `headroom wrap` | Notes |
+|---|:---:|---|
+| Claude Code | ✅ | `--memory` · `--code-graph` · `--1m` · `--tool-search` |
+| Codex | ✅ | shares memory with Claude |
+| Grok CLI | ✅ | routes via `GROK_MODELS_BASE_URL` |
+| Cursor | Manual setup | starts the proxy and prints base URLs for Cursor settings |
+| Aider | ✅ | starts proxy + launches |
+| Copilot CLI | ✅ | starts proxy + launches |
+| VS Code Copilot | ✅ | transparent proxy; keeps the selected model |
+| OpenClaw | ✅ | installs as a ContextEngine plugin |
+| OpenCode | ✅ | injects config · starts proxy + launches |
+| Cline | ✅ | starts proxy + injects config |
+| Continue | ✅ | starts proxy + injects config |
+| Goose | ✅ | starts proxy + launches |
+| OpenHands | ✅ | starts proxy + launches |
+| Mistral Vibe | ✅ | starts proxy + launches |
+| Oh My Pi | ✅ | injects config · starts proxy + launches |
+| Cortex Code | Library only | 60–65% savings in library mode; no `wrap` |
+| Kimi CLI | ✅ | OAuth bearer forwarded — log in once |
+| ZCode | ✅ | starts the proxy and prints base URLs for ZCode settings |
+
+Any OpenAI-compatible client works through `headroom proxy`. MCP-native clients:
+`headroom mcp install`. Undo durable wrapping with `headroom unwrap <tool>`
+(`claude`, `copilot`, `codex`, `grok`, `kimi`, `omp`, `opencode`, `openclaw`,
+`zcode`). Registry authors should use the canonical [`server.json`](server.json)
+rather than reconstructing the `headroom mcp serve` contract from prose.
+
+<details>
+<summary><b>GitHub Copilot CLI subscription mode</b></summary>
+
+Headroom can route Copilot CLI subscription traffic through the local proxy:
```bash
headroom copilot-auth login
headroom wrap copilot --subscription -- --model gpt-4o
```
-This lets Headroom intercept OpenAI-compatible Copilot CLI requests and apply the same proxy compression pipeline before forwarding to GitHub Copilot's hosted API. The wrapper exchanges Headroom's reusable GitHub OAuth token for Copilot's short-lived API token and prints the upstream endpoint as `COPILOT_PROVIDER_API_URL=...` during launch.
-
-`headroom copilot-auth login` stores a Headroom-specific Copilot OAuth token.
-This avoids relying on generic GitHub or Copilot CLI tokens that can read
-Copilot account metadata but may still be rejected by Copilot's token-exchange
-endpoint.
+The wrapper exchanges Headroom's reusable GitHub OAuth token for Copilot's
+short-lived API token and prints the upstream endpoint as
+`COPILOT_PROVIDER_API_URL=...` at launch. `headroom copilot-auth login` stores a
+Headroom-specific Copilot OAuth token, rather than relying on generic GitHub or
+Copilot CLI tokens that can read account metadata but are still rejected by
+Copilot's token-exchange endpoint.
-For GitHub Enterprise Server or custom-domain Copilot deployments, set one of
-these before launching:
+For GitHub Enterprise Server or a custom-domain Copilot deployment, set one of
+these before launching. If both are set, the URL wins:
```bash
export GITHUB_COPILOT_ENTERPRISE_DOMAIN=ghe.example.com
-# or
export GITHUB_COPILOT_ENTERPRISE_URL=https://ghe.example.com
```
-Both variables are supported. If both are set,
-`GITHUB_COPILOT_ENTERPRISE_URL` takes precedence.
-
For GitHub.com Enterprise Cloud URLs such as
-`github.com/enterprises/your-enterprise`, do not set an enterprise-domain
-override. Headroom uses GitHub's normal token-exchange endpoint and the Copilot
-API endpoint advertised for the signed-in account.
-
-Platform support note: macOS auth reuse via Copilot CLI Keychain storage and
-Windows Headroom device authentication have been live-tested. Copilot CLI 1.0.81
-does not expose its working Windows login through the legacy Credential Manager
-schema Headroom recognizes, so run `headroom copilot-auth login` on Windows.
-Linux Secret Service / `secret-tool` reuse still needs real OS validation. For
-Docker and CI, prefer passing an explicit `GITHUB_COPILOT_TOKEN` or
-`GITHUB_COPILOT_GITHUB_TOKEN` rather than relying on host keychain access.
-
-### GitHub Copilot in Visual Studio Code
-
-Headroom transparently overrides Copilot's API proxy endpoint, so the normal VS
-Code model picker remains authoritative. GPT-5.5, GPT-5.6 Luna/Sol/Terra, Claude
-Sonnet/Opus, and other Copilot models keep their original model IDs while traffic
-passes through the local compression proxy. Headroom does not patch VS Code or
-change Codex settings:
+`github.com/enterprises/your-enterprise`, set neither — Headroom uses GitHub's
+normal token-exchange endpoint and the Copilot API endpoint advertised for the
+signed-in account.
+
+**Platform support.** macOS auth reuse through Copilot CLI Keychain storage and
+Windows device authentication are live-tested. Copilot CLI 1.0.81 does not expose
+its Windows login through the legacy Credential Manager schema Headroom reads, so
+run `headroom copilot-auth login` on Windows. Linux Secret Service /
+`secret-tool` reuse is implemented but not yet validated on a real desktop. In
+Docker and CI, pass an explicit `GITHUB_COPILOT_TOKEN` or
+`GITHUB_COPILOT_GITHUB_TOKEN` instead of relying on host keychain access.
+
+</details>
+
+<details>
+<summary><b>GitHub Copilot in VS Code</b></summary>
+
+Headroom overrides Copilot's API proxy endpoint, so the VS Code model picker
+stays authoritative. GPT-5.5, GPT-5.6 Luna/Sol/Terra, Claude Sonnet/Opus and
+other Copilot models keep their original model IDs while traffic passes through
+the local compression proxy. Headroom does not patch VS Code or change Codex
+settings.
```bash
headroom copilot-auth login
headroom wrap vscode
```
-Keep the command running and use Copilot normally. Headroom holds the short-lived
-upstream Copilot token only in the proxy process.
-See the [cross-platform VS Code Copilot guide](https://docs.headroomlabs.ai/docs/vscode-copilot)
-for paths, credential flow, remote-development notes, undo steps, and troubleshooting.
+Keep the command running and use Copilot normally. The short-lived upstream
+Copilot token is held only in the proxy process.
+[Full guide →](https://docs.headroomlabs.ai/docs/vscode-copilot)
-### Claude Code in Visual Studio Code
+</details>
+
+<details>
+<summary><b>Claude Code in VS Code</b></summary>
The official Claude Code extension embeds Claude Code and reads the same user
-settings as the CLI. Install Headroom's proxy dependencies, then run the wrapper
-from the project you plan to open in VS Code:
+settings as the CLI. Install the proxy extra, then run the wrapper from the
+project you will open in VS Code:
```bash
pip install "headroom-ai[proxy]"
headroom wrap vscode-claude
```
-On the first run, reload the VS Code window. Keep the wrapper terminal running
-while you use the Claude Code panel; inspect the dashboard or proxy log printed
-at startup to see requests and savings.
-Headroom preserves your Anthropic authentication and selected model.
-
-Press `Ctrl+C` to stop the proxy. Restart the same command before using Claude
-Code again, or completely restore the settings that existed before setup:
+Reload the VS Code window on first run. Keep the wrapper terminal running while
+you use the Claude Code panel; the dashboard or proxy log printed at startup
+shows requests and savings. Your Anthropic authentication and selected model are
+preserved. `Ctrl+C` stops the proxy; `headroom unwrap vscode-claude` restores the
+settings that existed before setup.
+[Full guide →](https://docs.headroomlabs.ai/docs/vscode-claude-code)
-```bash
-headroom unwrap vscode-claude
-```
+</details>
-See the
-[VS Code Claude Code guide](https://docs.headroomlabs.ai/docs/vscode-claude-code)
-for verification, configuration paths, custom profiles, remote development, and
-troubleshooting.
+## When to use · when to skip
-## When to use · When to skip
+**Good fit if you** run coding agents daily and want savings without touching
+your code, work across several agents and want one shared memory, or need
+compression that is reversible — originals stay retrievable through CCR for the
+configured TTL.
-**Great fit if you…**
-- run AI coding agents daily and want savings without changing your code
-- work across multiple agents and want shared memory
-- need reversible compression — originals are retrievable via CCR within the configured TTL
+**Skip it if you** only use one provider's native compaction and don't need
+cross-agent memory, or work in a sandbox where local processes can't run.
-**Skip it if you…**
-- only use a single provider's native compaction and don't need cross-agent memory
-- work in a sandboxed environment where local processes can't run
+Headroom pays off on long agent sessions with heavy tool output. Short
+conversational exchanges, prose, and already-dense payloads see little or no
+reduction, and blocks under `min_input_words` come back byte-identical.
+[Limitations](https://docs.headroomlabs.ai/docs/limitations) has the full list.
<details>
<summary><b>Integrations — drop Headroom into any stack</b></summary>
-| Your setup | Hook in with |
-|------------------------|------------------------------------------------------------------|
-| Any Python app | `compress(messages, model=…)` |
-| Any TypeScript app | `await compress(messages, { model })` |
-| Anthropic / OpenAI SDK | `withHeadroom(new Anthropic())` · `withHeadroom(new OpenAI())` |
-| Vercel AI SDK | `wrapLanguageModel({ model, middleware: headroomMiddleware() })` |
-| LiteLLM | `litellm.callbacks = [HeadroomCallback()]` |
-| LangChain | `HeadroomChatModel(your_llm)` |
-| Agno | `HeadroomAgnoModel(your_model)` |
-| Strands | [Strands guide](https://docs.headroomlabs.ai/docs/strands) |
-| ASGI apps | `app.add_middleware(CompressionMiddleware)` |
-| Multi-agent | `SharedContext().put / .get` |
-| MCP clients | `headroom mcp install` |
+| Your setup | Hook in with |
+|---|---|
+| Any Python app | `compress(messages, model=…)` |
+| Any TypeScript app | `await compress(messages, { model })` |
+| Anthropic / OpenAI SDK | `withHeadroom(new Anthropic())` · `withHeadroom(new OpenAI())` |
+| Vercel AI SDK | `wrapLanguageModel({ model, middleware: headroomMiddleware() })` |
+| LiteLLM | `litellm.callbacks = [HeadroomCallback()]` |
+| LangChain | `HeadroomChatModel(your_llm)` |
+| Agno | `HeadroomAgnoModel(your_model)` |
+| Strands | [Strands guide](https://docs.headroomlabs.ai/docs/strands) |
+| ASGI apps | `app.add_middleware(CompressionMiddleware)` |
+| Multi-agent | `SharedContext().put / .get` |
+| MCP clients | `headroom mcp install` |
</details>
<details>
<summary><b>What's inside</b></summary>
-- **SmartCrusher** — universal JSON: arrays of dicts, nested objects, mixed types.
-- **CodeCompressor** — AST-aware for Python, JS/TS, Go, Rust, Java, C/C++, Perl.
+- **SmartCrusher** — universal JSON: arrays of dicts, nested objects, mixed types. It keeps error items, values outside the normal statistical range, and first/last boundaries, selected from field-variance statistics rather than a keyword list.
+- **CodeCompressor** — AST-aware for Python, JS/TS, Go, Rust, Java, C/C++ and Perl.
- **Kompress-v2-base** — our HuggingFace model, trained on agentic traces.
-- **Image compression** — 40–90% reduction via trained ML router.
-- **CacheAligner** - detects and warns about volatile content that can bust provider KV cache prefixes; never rewrites prompts.
-- **Live-zone compression** — compresses only new bytes (fresh tool output, latest turn); frozen prefix stays byte-identical so provider cache is not busted. History is never dropped.
-- **CCR** — reversible compression; LLM retrieves originals on demand.
-- **Cross-agent memory** — shared store, agent provenance, auto-dedup.
+- **Image compression** — 40–90% reduction through a trained ML router.
+- **CacheAligner** — flags volatile content that would bust a provider KV-cache prefix; never rewrites prompts.
+- **Live-zone compression** — only new bytes are compressed (fresh tool output, the latest turn). The frozen prefix stays byte-identical, so the provider cache survives, and history is never dropped.
+- **CCR** — reversible compression; the model retrieves originals on demand.
+- **Cross-agent memory** — shared store with agent provenance and auto-dedup.
- **SharedContext** — compressed context passing across multi-agent workflows.
-- **`headroom learn`** — plugin-based failure mining for Claude, Codex, Gemini.
+- **`headroom learn`** — plugin-based failure mining for Claude, Codex and Gemini.
</details>
<details>
<summary><b>Pipeline internals</b></summary>
-Headroom exposes one stable request lifecycle across `compress()`, the SDK, and the proxy:
+One request lifecycle is shared by `compress()`, the SDKs and the proxy:
-`Setup` → `Pre-Start` → `Post-Start` → `Input Received` → `Input Cached` → `Input Routed` → `Input Compressed` → `Input Remembered` → `Pre-Send` → `Post-Send` → `Response Received`
+`Setup` → `Pre-Start` → `Post-Start` → `Input Received` → `Input Cached` →
+`Input Routed` → `Input Compressed` → `Input Remembered` → `Pre-Send` →
+`Post-Send` → `Response Received`
-- **Transforms** do the work: CacheAligner → ContentRouter → SmartCrusher / CodeCompressor / Kompress-base (live-zone only; IntelligentContext and RollingWindow were retired in PR-B1).
-- **Pipeline extensions** observe or customize lifecycle stages via `on_pipeline_event(...)`.
-- **Compression hooks** sit alongside the canonical lifecycle as an additional extension seam.
-- **Proxy extensions** remain the server/app integration seam for ASGI middleware, routes, and startup policy.
+- **Transforms** do the work: CacheAligner → ContentRouter → SmartCrusher / CodeCompressor / Kompress-base, live-zone only. IntelligentContext and RollingWindow were retired in PR-B1.
+- **Pipeline extensions** observe or customise lifecycle stages through `on_pipeline_event(...)`.
+- **Compression hooks** sit alongside the lifecycle as an additional extension seam.
+- **Proxy extensions** are the integration seam for ASGI middleware, routes and startup policy.
-Provider and tool-specific behavior lives under `headroom/providers/` so core orchestration stays focused on lifecycle, sequencing, and policy.
+Provider- and tool-specific behaviour lives under `headroom/providers/`, so core
+orchestration stays focused on lifecycle, sequencing and policy:
-- **CLI/tool slices**: `headroom/providers/claude`, `copilot`, `codex`, `grok`, `openclaw`
-- **Provider runtime slices**: `headroom/providers/claude`, `gemini`, plus shared backend/runtime dispatch in `headroom/providers/registry.py`
-- **Core files stay orchestration-first**: `wrap.py`, `client.py`, `cli/proxy.py`, and `proxy/server.py` delegate provider-specific env shaping, API target normalization, backend selection, and transport dispatch.
+- CLI/tool slices — `headroom/providers/claude`, `copilot`, `codex`, `grok`, `openclaw`
+- Provider runtime slices — `headroom/providers/claude`, `gemini`, with shared backend dispatch in `headroom/providers/registry.py`
+- `wrap.py`, `client.py`, `cli/proxy.py` and `proxy/server.py` delegate env shaping, API target normalisation, backend selection and transport dispatch
</details>
-## Headroom for teams
-
-Headroom OSS is built for **individual developers**: run `headroom proxy` or `headroom wrap` on your laptop and start cutting tokens in minutes — free, local-first, your data never leaves your machine.
-
-Running it across a **whole engineering org** is a different job: a shared, always-on deployment; centralized config and version rollout; org-wide savings dashboards; SSO and access controls; air-gapped / VPC installs; and someone to call when it matters. That's what we help companies with — self-hosted with support, or fully managed.
-
-**If your team is spending real money on LLM tokens** — Claude Code, Codex, Cursor, or agents running in CI — **and you want those savings across everyone, not just one laptop:**
-
-→ Email **[[email protected]](mailto:[email protected])** with your stack and rough monthly LLM spend, and we'll help you roll Headroom out across your organization.
-
-Everything in this repo stays open source (Apache 2.0). The managed offering is simply for teams that would rather have it deployed, supported, and scaled for them.
-
## Install
```bash
uv tool install --python 3.13 "headroom-ai[all]" # CLI, isolated app env
-pip install "headroom-ai[all]" # Python, everything — includes the `headroom` CLI
-npm install headroom-ai # TypeScript SDK (library only — no `headroom` CLI)
+pip install "headroom-ai[all]" # Python, everything — includes the CLI
+npm install headroom-ai # TypeScript SDK (library only)
docker pull ghcr.io/headroomlabs-ai/headroom:latest
```
-Granular extras: `[proxy]`, `[mcp]`, `[ml]` (Kompress-v2-base), `[code]`, `[memory]`, `[vector]` (optional HNSW backend — needs a C++ toolchain, not in `[all]`), `[relevance]`, `[image]`, `[agno]`, `[langchain]`, `[evals]`, `[pytorch-mps]` (Apple-GPU memory-embedder offload — set `HEADROOM_EMBEDDER_RUNTIME=pytorch_mps`). Requires **Python 3.10+**.
+Granular extras: `[proxy]`, `[mcp]`, `[ml]` (Kompress-v2-base), `[code]`,
+`[memory]`, `[vector]` (optional HNSW backend — needs a C++ toolchain, not in
+`[all]`), `[relevance]`, `[image]`, `[agno]`, `[langchain]`, `[evals]`,
+`[pytorch-mps]` (Apple-GPU memory-embedder offload — set
+`HEADROOM_EMBEDDER_RUNTIME=pytorch_mps`). Requires **Python 3.10+**.
+
+> `[all]` covers the core stack but not the framework adapters. Install those
+> separately: `pip install "headroom-ai[langchain]"`, and likewise `[agno]`,
+> `[strands]`, `[anyllm]`, `[bedrock]`.
+
+> **Pick Python 3.13 if you want the dollar figure.** The dashboard's *Proxy $
+> Saved* tile prices compression with [LiteLLM](https://github.com/BerriAI/litellm),
+> which cannot be installed on Python 3.14+. Token savings still track on 3.14,
+> but the dollar figure stays `$0.00`. To switch:
+> `pipx reinstall headroom-ai --python python3.13`, then restart the proxy.
-> **Note**: `[all]` covers the core stack but excludes framework adapters. Install them separately: `pip install "headroom-ai[langchain]"` (also `[agno]`, `[strands]`, `[anyllm]`, `[bedrock]`).
+→ [Installation guide](https://docs.headroomlabs.ai/docs/installation) — Docker
+tags, persistent service, PowerShell, devcontainers.
+
+<details>
+<summary><b>uv, pipx, and MCP clients that don't inherit your PATH</b></summary>
-Using `uv` for the `headroom` CLI? Prefer `uv tool install` so the command lives in an isolated app environment. On macOS, pass `--python 3.13` if your default `python3` is newer than the current wheel set:
+Prefer `uv tool install` for the CLI so the command lives in an isolated app
+environment. On macOS, pass `--python 3.13` if your default `python3` is newer
+than the current wheel set:
```bash
-brew install [email protected] # if Python 3.13 is not already available
+brew install [email protected] # if 3.13 is not already available
uv tool install --python 3.13 "headroom-ai[all]"
-uv tool update-shell # if ~/.local/bin is not already on PATH
+uv tool update-shell # if ~/.local/bin is not on PATH
headroom --version
```
-For MCP clients such as Codex that do not inherit your interactive shell `PATH`, configure the absolute executable path returned by `command -v headroom`:
+Codex and other MCP clients often cannot inherit an interactive shell `PATH`.
+Configure the absolute path returned by `command -v headroom`:
```toml
[mcp_servers.headroom]
@@ -445,25 +457,28 @@ command = "/Users/you/.local/bin/headroom"
args = ["mcp", "serve"]
```
-Current native wheels cover macOS Apple Silicon and Linux. On Intel macOS, use Docker-native install until native wheel support lands.
+`command = "headroom"` only works when the client starts with a `PATH` that
+already includes the uv tool directory.
-Using `pipx`? Choose a supported interpreter explicitly:
+With pipx, choose the interpreter explicitly:
```bash
pipx install --python python3.13 "headroom-ai[all]"
```
-> **Pick 3.13 if you want dollar savings.** The dashboard's *Proxy $ Saved* tile prices compression with [LiteLLM](https://github.com/BerriAI/litellm), and LiteLLM can't be installed on Python 3.14+. On 3.14 token savings still track, but the dollar figure stays `$0.00`. If you already installed on 3.14, switch with `pipx reinstall headroom-ai --python python3.13` and restart the proxy.
+Native wheels currently cover macOS Apple Silicon and Linux. On Intel macOS, use
+the Docker-native install until native wheel support lands.
-→ [Installation guide](https://docs.headroomlabs.ai/docs/installation) — Docker tags, persistent service, PowerShell, devcontainers.
+**CPU requirement (x86/x86_64).** The ONNX-backed features — Magika content
+detection and embedding relevance — use a precompiled ONNX Runtime that needs
+**AVX2**. On x86 hosts without AVX2 (some Docker/QEMU setups, older cloud VMs)
+Headroom falls back to its non-ONNX paths — BM25 relevance, heuristic detection —
+rather than crashing. `arm64` and Apple Silicon need no AVX2.
-> **CPU requirement (x86/x86_64):** the ONNX-backed features — Magika content
-> detection and embedding relevance — use a precompiled ONNX Runtime that needs
-> **AVX2**. On x86 hosts without AVX2 (some Docker/QEMU setups and older cloud
-> VMs) Headroom automatically falls back to its non-ONNX paths (BM25 relevance,
-> heuristic detection) rather than crashing. `arm64`/Apple Silicon needs no AVX2.
+</details>
-### Updating
+<details>
+<summary><b>Updating</b></summary>
```bash
headroom update # detects pip / pipx / uv tool and upgrades in place
@@ -471,21 +486,25 @@ headroom update --check # report the latest release without upgrading
headroom update --pre # include pre-releases
```
-`headroom update` figures out how Headroom was installed (pip/venv, `pip --user`,
-pipx, uv tool) and runs the matching upgrade across macOS, Linux, and Windows.
-For git checkouts, editable installs, Docker images, and externally-managed
-system Pythons (PEP 668) it prints the correct manual step instead of guessing.
+`headroom update` works out how Headroom was installed (pip/venv, `pip --user`,
+pipx, uv tool) and runs the matching upgrade on macOS, Linux and Windows. For git
+checkouts, editable installs, Docker images and externally-managed system Pythons
+(PEP 668) it prints the correct manual step instead of guessing.
-The proxy also shows a one-line "update available" notice on startup. It checks
+The proxy also prints a one-line "update available" notice at startup. It checks
PyPI at most once a day, in the background, and never blocks. Opt out with
-`HEADROOM_UPDATE_CHECK=off` (also skipped in `--stateless` mode and CI).
+`HEADROOM_UPDATE_CHECK=off`; it is also skipped in `--stateless` mode and CI.
-### Corporate / SSL-inspection environments
+</details>
+
+<details>
+<summary><b>Corporate networks and SSL inspection</b></summary>
If `pip install "headroom-ai[all]"` fails with `CERTIFICATE_VERIFY_FAILED`
-(`unable to get local issuer certificate`), your network uses **SSL inspection** — a MITM
-proxy presenting a company-issued CA. The build backend (`maturin`) downloads `rustup` over a
-connection your TLS stack doesn't trust. **Install Rust first** so the build doesn't fetch it:
+(`unable to get local issuer certificate`), your network runs SSL inspection — a
+MITM proxy presenting a company CA. The build backend (`maturin`) downloads
+`rustup` over a connection your TLS stack does not trust. Install Rust first so
+the build never fetches it:
```bash
# macOS / Linux
@@ -494,28 +513,23 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh && rustup default
winget install Rustlang.Rustup && rustup default stable
```
-Restart your shell, then `pip install "headroom-ai[all]"`. A prebuilt wheel avoids the Rust
-build entirely where available: `pip install --only-binary headroom-ai headroom-ai`. Prebuilt
-wheels are published for Windows (`win_amd64`), Linux (`x86_64` / `aarch64`), and macOS
-(Apple Silicon and Intel), so installs on those platforms never need a local Rust toolchain — the
-Rust-first dance above is only for the platform-independent sdist fallback when no wheel matches.
-
-Two runtime assets are fetched over TLS; if they are blocked, trust your corporate CA via
-`REQUESTS_CA_BUNDLE` / `SSL_CERT_FILE` / `CURL_CA_BUNDLE`:
+Restart your shell, then install. A prebuilt wheel avoids the Rust build
+entirely: `pip install --only-binary headroom-ai headroom-ai`. Wheels are
+published for Windows (`win_amd64`), Linux (`x86_64` / `aarch64`) and macOS
+(Apple Silicon and Intel), so those platforms never need a local Rust toolchain —
+the Rust-first step above is only for the sdist fallback when no wheel matches.
-- **`cdn.pyke.io`** — the ONNX Runtime for the Rust core. Alternatively pre-provide it with
- `ORT_STRATEGY=system` and `ORT_LIB_LOCATION=/path/to/onnxruntime`.
-- **`huggingface.co`** — the `kompress-base` compression model. Pre-download it and run with
- `HF_HUB_OFFLINE=1`, or set `HF_ENDPOINT` to a trusted mirror.
+Two runtime assets are fetched over TLS. If they are blocked, trust your
+corporate CA through `REQUESTS_CA_BUNDLE` / `SSL_CERT_FILE` / `CURL_CA_BUNDLE`:
-Running with compression disabled (pure gateway) requires neither asset.
+- **`cdn.pyke.io`** — the ONNX Runtime for the Rust core. Or pre-provide it with `ORT_STRATEGY=system` and `ORT_LIB_LOCATION=/path/to/onnxruntime`.
+- **`huggingface.co`** — the `kompress-base` model. Pre-download it and run with `HF_HUB_OFFLINE=1`, or point `HF_ENDPOINT` at a trusted mirror.
-#### Intel macOS (x86_64-apple-darwin): no prebuilt ONNX Runtime binary (#941)
+Running with compression disabled (pure gateway) needs neither asset.
-`ort-sys` ships no prebuilt ONNX Runtime binary for Intel macOS, so a source
-build fails by default even outside a corporate-proxy environment. The same
-`ORT_STRATEGY=system` mechanism above fixes it — point it at a system ONNX
-Runtime instead:
+**Intel macOS: no prebuilt ONNX Runtime ([#941](https://github.com/headroomlabs-ai/headroom/issues/941)).**
+`ort-sys` ships no prebuilt binary for `x86_64-apple-darwin`, so a source build
+fails by default even outside a corporate proxy. Point it at a system runtime:
```bash
brew install onnxruntime
@@ -528,70 +542,110 @@ ORT_PREFER_DYNAMIC_LINK=1 \
export ORT_DYLIB_PATH="$(brew --prefix onnxruntime)/lib/libonnxruntime.dylib"
```
-`ORT_LIB_LOCATION` must point at `lib/` (not the bare prefix) and
-`ORT_PREFER_DYNAMIC_LINK=1` is required, or `ORT_STRATEGY=system` still
-attempts static linking, which the Homebrew keg doesn't provide.
-
-#### "Basic Constraints of CA cert not marked critical" (Python 3.13+ strict mode)
+`ORT_LIB_LOCATION` must point at `lib/`, not the bare prefix, and
+`ORT_PREFER_DYNAMIC_LINK=1` is required — without it `ORT_STRATEGY=system` still
+attempts static linking, which the Homebrew keg does not provide.
-A **different** failure from the one above. If TLS fails with:
+**"Basic Constraints of CA cert not marked critical"** is a different failure. If
+TLS fails with:
```
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed:
Basic Constraints of CA cert not marked critical
```
-then the corporate CA *is* found and trusted — adding it to a CA bundle changes nothing.
-Python 3.13 + OpenSSL 3.x enable `VERIFY_X509_STRICT` by default, which enforces RFC 5280
-§4.2.1.9: a CA cert's `basicConstraints` must be marked *critical*. Inspection roots like
-Zscaler set `CA:TRUE` without the critical bit, so the chain is rejected.
+then the corporate CA *is* found and trusted, and adding it to a CA bundle
+changes nothing. Python 3.13 with OpenSSL 3.x enables `VERIFY_X509_STRICT` by
+default, which enforces RFC 5280 §4.2.1.9: a CA cert's `basicConstraints` must be
+marked critical. Inspection roots such as Zscaler set `CA:TRUE` without the
+critical bit, so the chain is rejected.
-Set **`HEADROOM_TLS_STRICT=0`** to clear *only* the strict flag from every TLS context
-Headroom controls — the proxy's httpx upstream client **and** the urllib3/`huggingface_hub`
-path used for model downloads. Chain validation, signature, expiry, and hostname checks all
-stay on; this is strictly narrower than disabling verification.
+`HEADROOM_TLS_STRICT=0` clears only the strict flag, from every TLS context
+Headroom controls — the proxy's httpx upstream client and the
+urllib3/`huggingface_hub` path used for model downloads. Chain validation,
+signature, expiry and hostname checks all stay on.
```bash
HEADROOM_TLS_STRICT=0 headroom proxy --port 8787
```
-The Rust core's ONNX download (`cdn.pyke.io`) uses a separate TLS stack (rustls / OS trust
-store), unaffected by `HEADROOM_TLS_STRICT`. On Windows the corporate root must be in the
-**machine** certificate store (browsers already trust it there); or pre-provision ONNX
-Runtime with `ORT_STRATEGY=system` + `ORT_LIB_LOCATION=/path/to/onnxruntime` to skip the
-download entirely.
+The Rust core's ONNX download uses a separate TLS stack (rustls / OS trust store)
+and is unaffected by `HEADROOM_TLS_STRICT`. On Windows the corporate root must be
+in the **machine** certificate store — browsers already trust it there — or
+pre-provision ONNX Runtime with `ORT_STRATEGY=system` to skip the download.
+
+</details>
## headroom learn
-<p align="center">
- <img src="headroom_learn.gif" alt="headroom learn in action" width="720">
-</p>
+<div align="center">
+ <img src="headroom_learn.gif" alt="headroom learn mining failed sessions and writing corrections" width="720">
+</div>
+
+`headroom learn` mines failed sessions and writes corrections to
+`CLAUDE.local.md` (default, gitignored; use `--target CLAUDE.md` for the shared
+team file), `AGENTS.md` or `GEMINI.md`.
+→ [Failure learning](https://docs.headroomlabs.ai/docs/failure-learning)
+
+## Telemetry
+
+An anonymous beacon is **on by default**. It reports how compression behaved:
+ratios, counters, provider and model IDs, OS and architecture. It never sends
+prompts, completions, code or file paths. It exists so we can see when a release
+regresses a compression ratio across real workloads rather than only our own test
+corpus.
-`headroom learn` — mines failed sessions, writes corrections to `CLAUDE.local.md` (default, gitignored; use `--target CLAUDE.md` for the shared team file) / `AGENTS.md` / `GEMINI.md`.
+Turn it off with `HEADROOM_BEACON=off`, the `DO_NOT_TRACK=1` convention, or
+`--offline`. The full field list is in
+[the proxy docs](https://docs.headroomlabs.ai/docs/proxy).
+
+## Headroom for teams
+
+Headroom OSS is built for individual developers: run `headroom proxy` or
+`headroom wrap` on your laptop and start cutting tokens in minutes, free and
+local-first.
+
+Running it across an engineering org is a different job — a shared always-on
+deployment, centralised config and version rollout, org-wide savings dashboards,
+SSO and access control, air-gapped and VPC installs, and someone to call. We help
+companies with that, self-hosted with support or fully managed.
+
+If your team is spending real money on LLM tokens — Claude Code, Codex, Cursor,
+or agents running in CI — email **[[email protected]](mailto:[email protected])**
+with your stack and rough monthly LLM spend.
+
+Everything in this repo stays open source under Apache 2.0. The managed offering
+is for teams that would rather have it deployed, supported and scaled for them.
## Documentation
-| Start here | Go deeper |
-|-------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
-| [Quickstart](https://docs.headroomlabs.ai/docs/quickstart) | [Architecture](https://docs.headroomlabs.ai/docs/architecture) |
-| [Proxy](https://docs.headroomlabs.ai/docs/proxy) | [How compression works](https://docs.headroomlabs.ai/docs/how-compression-works) |
-| [MCP tools](https://docs.headroomlabs.ai/docs/mcp) | [CCR — reversible compression](https://docs.headroomlabs.ai/docs/ccr) |
-| [Memory](https://docs.headroomlabs.ai/docs/memory) | [Cache optimization](https://docs.headroomlabs.ai/docs/cache-optimization) |
-| [Failure learning](https://docs.headroomlabs.ai/docs/failure-learning) | [Benchmarks](https://docs.headroomlabs.ai/docs/benchmarks) |
-| [Configuration](https://docs.headroomlabs.ai/docs/configuration) | [Limitations](https://docs.headroomlabs.ai/docs/limitations) |
-| [Persistent installs](https://docs.headroomlabs.ai/docs/persistent-installs) (`headroom init` / `headroom install apply`) | [Savings analytics](https://docs.headroomlabs.ai/docs/savings) (`headroom savings` / `headroom perf` / `headroom doctor`) |
+| Start here | Go deeper |
+|---|---|
+| [Quickstart](https://docs.headroomlabs.ai/docs/quickstart) | [Architecture](https://docs.headroomlabs.ai/docs/architecture) |
+| [Proxy](https://docs.headroomlabs.ai/docs/proxy) | [How compression works](https://docs.headroomlabs.ai/docs/how-compression-works) |
+| [MCP tools](https://docs.headroomlabs.ai/docs/mcp) | [CCR — reversible compression](https://docs.headroomlabs.ai/docs/ccr) |
+| [Memory](https://docs.headroomlabs.ai/docs/memory) | [Cache optimization](https://docs.headroomlabs.ai/docs/cache-optimization) |
+| [Failure learning](https://docs.headroomlabs.ai/docs/failure-learning) | [Benchmarks](https://docs.headroomlabs.ai/docs/benchmarks) |
+| [Configuration](https://docs.headroomlabs.ai/docs/configuration) | [Limitations](https://docs.headroomlabs.ai/docs/limitations) |
+| [Persistent installs](https://docs.headroomlabs.ai/docs/persistent-installs) | [Savings analytics](https://docs.headroomlabs.ai/docs/savings) |
## Compared to
-Headroom runs **locally**, covers **every** content type, works with every major framework, and is **reversible**.
+Headroom runs locally, covers every content type, works with every major
+framework, and is reversible.
-| | Scope | Deploy | Local | Reversible |
-|------------------------------------------------------------------------------|------------------------------------------------|------------------------------------|:-----:|:----------:|
-| **Headroom** | All context — tools, RAG, logs, files, history | Proxy · library · middleware · MCP | Yes | Yes |
-| [Compresr](https://compresr.ai), [Token Co.](https://thetokencompany.ai) | Text sent to their API | Hosted API call | No | No |
-| OpenAI Compaction | Conversation history | Provider-native | No | No |
+| | Scope | Deploy | Local | Reversible |
+|---|---|---|:---:|:---:|
+| **Headroom** | All context — tools, RAG, logs, files, history | Proxy · library · middleware · MCP | Yes | Yes |
+| [Compresr](https://compresr.ai), [Token Co.](https://thetokencompany.ai) | Text sent to their API | Hosted API call | No | No |
+| OpenAI Compaction | Conversation history | Provider-native | No | No |
-> **Stack & integrations.** Headroom is the **proxy** — that's what we build and offer, and it compresses everything flowing through it no matter what sits upstream. Our recommended companion is **[Serena](https://github.com/oraios/serena)** (installed by default when you wrap an agent) for semantic code navigation — plus **Ponytail** if you want leaner model output. Everything else is your call: you're free to attach your own tooling — code-memory MCP, Graphify, Caveman, or any MCP server — and Headroom compresses downstream of all of it.
+Headroom is the proxy, and it compresses everything flowing through it whatever
+sits upstream. Our recommended companion is
+**[Serena](https://github.com/oraios/serena)** for semantic code navigation,
+installed by default when you wrap an agent, plus **Ponytail** if you want leaner
+model output. Everything else is your call — attach a code-memory MCP, Graphify,
+Caveman, or any other MCP server, and Headroom compresses downstream of all of it.
## Contributing
@@ -600,16 +654,14 @@ git clone https://github.com/headroomlabs-ai/headroom.git && cd headroom
uv sync --extra dev && uv run pytest
```
-Devcontainers in `.devcontainer/` (default + `memory-stack` with Qdrant & Neo4j). See [CONTRIBUTING.md](CONTRIBUTING.md).
+Devcontainers in `.devcontainer/` (default, plus `memory-stack` with Qdrant and
+Neo4j). See [CONTRIBUTING.md](CONTRIBUTING.md).
## Community
- **[Discord](https://discord.gg/yRmaUNpsPJ)** — questions, feedback, war stories.
-- **[Kompress-v2-base on HuggingFace](https://huggingface.co/chopratejas/kompress-v2-base)** — the model behind our text compression.
-
-### Community projects
-
-- **[Claude Code status-line indicator](https://github.com/Ship-Wright/headroom-plugin)** — a Claude Code plugin that shows live Headroom usage in your status line: idle until `headroom_compress` fires, then the running total of tokens saved.
+- **[Kompress-v2-base on HuggingFace](https://huggingface.co/chopratejas/kompress-v2-base)** — the model behind text compression.
+- **[Claude Code status-line plugin](https://github.com/Ship-Wright/headroom-plugin)** — live token savings in your status line, by [@Ship-Wright](https://github.com/Ship-Wright).
## License