← Back to Leaderboard
Hheadroomlabs-ai

headroomlabs-ai/headroom

Local context compression for LLMs via a Python library, proxy, and MCP server

Engineering Health (Methodology)
A+ · 96/100
Maintenance Activity
● Updated today
Latest Release
v0.45.0
Commercial License Check
Apache-2.0 · Commercial Friendly

Automated SPDX check for reference only — not legal advice. Disclaimer

Maintenance35/35
Fork Adoption21/25
Release Cadence20/20
License Clarity20/20
DockerSelf-HostedLocal AICLIMCPAPI
Total Stars
★ 81,468
24h Growth
+43
7d Growth
+455
Forks
6,426

GitHub Star History

Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.

headroomlabs-ai/headroom Star History (2026-01-10 - 2026-12-04) ALL-TIME STAR HISTORY (2026-01 – 2026-12) +81.5k in 328d · avg +248/day 86k 43k 0 2026-01-10: ★ 12026-01-31: ★ 3722026-02-21: ★ 5302026-03-14: ★ 6642026-04-04: ★ 1,0612026-04-25: ★ 1,4932026-05-16: ★ 1,7122026-06-06: ★ 15,5842026-06-27: ★ 51,4102026-07-18: ★ 58,6712026-08-08: ★ 64,5322026-08-29: ★ 67,2392026-09-19: ★ 72,4492026-10-10: ★ 74,5282026-10-31: ★ 78,2342026-11-20: ★ 80,1532026-12-04: ★ 81,468 ★ 81.5k 2026-01 2026-06 2026-12

Evidence-Backed Technical Brief

AI Deep Review

Architecture & Core Mechanics

Headroom preprocesses LLM messages through an in-process Python library, a request proxy, or callable MCP tools. ContentRouter dispatches JSON to SmartCrusher, source code to the AST-based CodeCompressor, and eligible prose to a Kompress-v2-base path. CacheAligner flags volatile content that could break a provider’s cached prefix without rewriting it. CCR retains originals locally so the model can recover details through headroom_retrieve rather than requiring every request to carry the full payload.

The headroom-ai Python package requires Python 3.11 or newer and uses Maturin to build the PyO3 extension. The Cargo workspace separates headroom-core, headroom-proxy, the Python bindings, and simulator and parity crates. The npm package is a TypeScript SDK that calls the proxy, not a standalone compressor or CLI. MCP exposes headroom_compress, headroom_retrieve, and headroom_stats as explicit tools rather than transparently intercepting traffic.

Key Capabilities & Differentiators

The default library path compresses tool and assistant messages while leaving user messages untouched unless compress_user_messages=True is set. Wrapped agents include Claude Code and Codex; Cursor uses manual proxy configuration. Optional output shaping adds verbosity guidance to the system prompt for Anthropic /v1/messages and OpenAI-compatible /v1/chat/completions and /v1/responses. Cross-agent memory and headroom learn address different needs: sharing context across supported agents and turning lessons from failed sessions into editable instruction files.

Seeded offline tests using provider tokenizers and default compress() settings reduced input tokens by 21% for code search, 57% for SRE incident debugging, 42% for codebase exploration, and 30% for GitHub issue triage. Repeated JSON arrays and log lines exceeded 90% in separate benchmarks. Those results describe payloads, not production cost or answer quality. The 100-example GSM8K test matched baseline at 0.870, and the TruthfulQA difference was within the reported confidence interval. Output savings are a separate metric: HEADROOM_OUTPUT_HOLDOUT=0.1 reserves unshaped conversations as a control instead of relying on a modeled baseline.

Trade-offs & Limitations

The strongest case for Headroom over direct provider calls is a workload dominated by repeated structured tool output. Compared with provider-native compaction, it offers preprocessing across supported clients and a way to recover originals; it also adds another component that can affect request routing, task quality, and latency. CCR only makes compression reversible while the original is retained and the agent can use the retrieval tool. Short prompts and dense prose leave little room for savings. Validate task success and retrieval frequency before rolling it out on correctness-sensitive workflows.

In-process compression minimizes operational dependencies, while the proxy is useful when you do not control the client or want shared memory. A reported 0.21 ms p50 for a 10K-token JSON result is a compression microbenchmark, not end-to-end proxy latency or a result for prose inference. Measure upstream cache behavior along with token usage. On a reused shared proxy, runtime overrides synced by headroom wrap are global and the last explicit setting wins; teams needing different output policies should not assume those settings are isolated by session.

Hardware & Deployment Guide

For an application you control, start with pip install headroom-ai and call compress() before the provider SDK. The basic path needs neither a Headroom API key nor a model download; HEADROOM_OFFLINE=1 keeps compression offline, not the downstream provider call. For agents, uv tool install --python 3.13 "headroom-ai[all]" provides the CLI. headroom wrap claude runs a session-scoped proxy, while headroom deploy is the persistent local option. Set --openai-api-url or OPENAI_TARGET_API_URL for a third-party OpenAI-compatible upstream; wrapping otherwise defaults that traffic to OpenAI.

For Docker, run the proxy alone if semantic memory is unnecessary. The Compose stack adds Qdrant and Neo4j; set real NEO4J_AUTH credentials before non-local use. The standalone example publishes port 8787 only on host loopback and explicitly acknowledges the unauthenticated container bind; do not reuse that configuration for a remotely exposed service. Release v0.44.0 stopped including PyTorch extras in [all], so do not assume that install includes them. v0.45.0 added repeatable --extra-model flags for OpenCode wrapping. Size the runtime against payload mix, concurrency, and retained data, and assess optional prose inference separately.

Content-aware compression: SmartCrusher handles JSON, CodeCompressor uses ASTs for source, and Kompress-v2-base provides a prose path.
Original recovery: CCR exposes retained originals through headroom_retrieve within the configured TTL.
Cache diagnostics: CacheAligner flags volatile content that can invalidate a provider’s cached prefix without rewriting prompts.
Reproducible measurements: Seeded offline tests using default compress() settings show 21–57% fewer input tokens across four scenarios.
Integration boundaries: Python can run in-process, TypeScript calls the proxy, and MCP clients get explicit compress, retrieve, and stats tools.
Output controls: Opt-in verbosity steering supports Anthropic Messages and OpenAI-compatible Chat Completions and Responses; a conversation holdout separates measured savings from modeled estimates.
Best For

Coding agents and LLM applications where repeated JSON tool results, logs, or search hits dominate input tokens, especially when you need recoverable originals or a common preprocessing layer across clients.

Skip If

Most requests are short or prose-heavy, provider-native compaction already meets your needs, or you cannot accept either temporary retention of originals or the risk of losing detail when retrieval is unavailable.

Reviewed on 2026-12-02 · Grounded in GitHub README, root file tree & releasesMethodology

Quick Start & Installation

DockerSelf-HostedLocal AICLI
pip install headroom-ai

Comparison vs. Top Coding, Skills & MCP Alternatives

Full comparison →
RepositoryStars7d TrendStackLicenseCore Positioning
headroom ★81.5k+455PythonApache-2.0Local context compression for LLMs via a Python library, proxy, and MCP server
agents43.2k+212PythonMITOne Markdown plugin catalog adapted to seven AI coding tools
graphify156.8k+2.4kPythonApache-2.0Local AST graphs for dependency tracing, with CLI and MCP access.
oh-my-pi40.5k+483TypeScriptMITA Bun/Rust terminal agent for model-flexible coding with LSP and editor integrat

AI Context Briefing (for Claude / Cursor / Windsurf)

Standardized architecture summary & quickstart commands ready to paste into coding agents.

Raw .md ↗
curl -sL https://repoforai.com/repo/headroomlabs-ai/headroom.md

Embed Star History Chart & Badges in README.md

Full-history Star History SVGs and velocity cards on GitHub Camo: drop-in replacement for OSSInsight and Star History widgets.

headroomlabs-ai/headroom Star History on RepoForAI

Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).

Frequently Asked Questions about headroom

Should I integrate the library, proxy, or MCP server?

Use Python’s compress(messages, model=…) when you own the message-building code. For TypeScript, the npm SDK sends messages to a running Headroom proxy; it does not ship the CLI. For a supported coding agent, headroom wrap starts and configures the proxy for the session. An MCP client can call headroom_compress, headroom_retrieve, and headroom_stats explicitly; installing those tools is not the same as routing every model request through the proxy.

Do I need a GPU, and what should I size for?

The basic in-process Python path needs no model download, so start by measuring CPU time and memory with representative payload sizes and concurrency rather than budgeting for a GPU. Size local prose-model inference separately if you choose to use it; no fixed VRAM requirement is specified. For a shared deployment, also account for originals retained by CCR and, if semantic memory is enabled, the Qdrant and Neo4j services.

Can we self-host it commercially, and what data-handling rules still apply?

Headroom is Apache-2.0 licensed, which permits commercial self-hosting. Preserve applicable license and notice materials when redistributing it, and review any separately deployed models or dependencies on their own terms. Local compression is not a guarantee that data stays on-premises: the configured upstream receives the compressed request, and CCR keeps original content locally for the configured TTL. Review routing, access controls, and retention before processing sensitive workloads.

When is Headroom preferable to provider-native compaction?

Provider-native compaction is the simpler choice if its behavior already meets your requirements. Headroom is worth testing when repeated tool payloads dominate token use, several supported clients need the same preprocessing layer, or the agent needs to recover omitted details during the CCR retention window. Compare cost per completed task and task success, not just token counts; retrieval adds work that an input-savings percentage does not capture.

Upstream README & Documentation

This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.

Maintaining headroomlabs-ai/headroom? Pin to Homepage + competitor /alternatives pages with a custom Cloud/Demo CTA.Feature headroomlabs-ai/headroom on Homepage & Alternatives ($19)
WEEKLY BREAKOUT DIGEST

Top 10 Breakout Open-Source AI Repos, Every Thursday

Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.

Zero spam · 1-click unsubscribe · Privacy Policy

Saved in your browser · Export Markdown RFC tables or jump into /vs compare