Headroom: Compress tool outputs, logs, files, and RAG chunks before they reach the LLM
headroomlabs-ai/headroomCompress 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.
Evaluate and collect.
What the project says.
Quickstart · Headroom for Teams · Install · Proof · Agents · Docs · Discord · llms.txt AI agents / LLMs: read /llms.txt here, or fetch the live index · full docs blob . Headroom ( headroom-ai on PyPI and npm) compresses everything your AI agent reads - tool outputs, logs, RAG chunks, files, and conversation history - before it reaches the LLM. Same answers, fewer input tokens. Measured: 21–57% fewer input tokens on four agent scenarios, 90%+ on repeated JSON arrays and log lines, little on prose (Proof). Compression runs on your machine; no prompt or file content is sent anywhere to be compressed. Start here My app calls an LLM (Python, LangChain, LiteLLM, Agno, Strands): No API key, no model download, in-process. Set HEADROOM OFFLINE=1 for a zero-network run. Tool and assistant messages are compressed; user messages are left alone unless you pass compress user messages=True . FastAPI example · API reference. TypeScript apps: npm install headroom-ai plus the proxy ( pip install "headroom-ai[proxy]" , headroom proxy --port 8787 ); the npm SDK sends messages to it. TypeScript quickstart I run coding agents (Claude Code, Codex, Cursor, Copilot, OpenCode, Aider): Zero code changes. Agent compatibility · Proxy 10,144 → 1,260 tokens. The same FATAL found. 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 droid zcode in one command; undo with headroom unwrap . - 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. - Reversible (CCR) - originals are cached locally and retrieved on demand. How it works - 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 · CCR · Kompress-v2-base model card Get started (60 seconds) Reduce input tokens in your own app Launch a wrapped agent session each time, so the setup runs. headroom wrap starts a local proxy and launches the agent configured to route through Headroom. Add --code-memory serena to also install Serena for semantic code navigation (off by default). For Claude Code, Serena is registered for the wrapped project only (as a local -scope MCP server in /.claude.json ); use --code-memory-scope user to make it available in every project. headroom unwrap removes either registration. headroom wrap ... is session-scoped: its proxy exits with the wrapped agent. For a proxy that survives reboots, use the turnkey headroom deploy command. Use headroom install apply when you need to choose a specific persistent service, scheduled task, Docker runtime, scope, or provider target; see the persistent installs guide. 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. Proof: measured token savings Four scenarios built from real MCP server output formats, measured with the provider tokenizer and the shipped compress() at its default configuration. Seeded and offline, so you get the same numbers we did: Scenario Before After Saved --- ---: ---: ---: Code search (100 results) 17,199 13,597 21% SRE incident debugging ...
Continue the conversation.
Comments, one-level replies, owner highlights, and discussion notifications are included with ORYNT membership.
Sign in with GitHub