AGENTCONN
H

// Agent profile

Headroom

Coding Free

About Headroom

Headroom by Headroom Labs is an open-source context compression tool that sits between your agent's orchestrator and the LLM API. It intercepts outbound context — tool results, file contents, conversation history, RAG chunks — and compresses it using specialized strategies: SmartCrusher for JSON (keeps error items, statistical outliers, first/last boundaries), CodeCompressor for AST-aware code compression across 8 languages (Python, JS/TS, Go, Rust, Java, C/C++, C#, PHP), and Kompress-v2-base (a custom model trained on agentic traces for prose). Available as a Python/Node library, a drop-in proxy (`headroom proxy --port 8787`), an agent wrapper (`headroom wrap <agent>`), or an MCP server. CacheAligner flags volatile content to preserve provider KV-cache prefixes. CCR mode stores originals locally for reversible compression — the model can call `headroom_retrieve` to get the full text on demand. Cross-agent memory shares context across Claude, Codex, Gemini, and Grok. `headroom learn` mines failed sessions and writes corrections to CLAUDE.local.md or AGENTS.md. 77K+ stars, 6K forks. Apache 2.0 licensed.

Key Features

  • 20–95% token reduction on tool outputs, logs, RAG chunks, and JSON
  • Four install modes: library, proxy, agent wrap, MCP server
  • AST-aware code compression for Python, JS/TS, Go, Rust, Java, C/C++, C#, PHP
  • CacheAligner stabilizes prefixes for Anthropic/OpenAI KV cache hits
  • CCR reversible compression — LLM can retrieve originals on demand
  • Cross-agent memory — shared store across Claude, Codex, Gemini, and Grok
  • headroom learn — mines failed sessions to write agent corrections
  • Live-zone compression — only compresses new content, preserving prefix stability
  • Image compression with 40–90% reduction
  • Compatible with Claude Code, Codex, Grok CLI, Aider, Copilot CLI, Cursor, Cline, and 10+ more

Overview

Headroom compresses everything your AI agent reads — tool outputs, logs, files, RAG chunks, and conversation history — before it reaches the LLM. The tool achieves 20% fewer tokens for coding agents and 60–95% fewer tokens for JSON, while maintaining answer quality as validated on GSM8K (unchanged at 0.870), TruthfulQA (+0.030 within confidence interval), and SQuAD v2 + BFCL (97% accuracy at 19–32% compression). Compression takes under a millisecond (0.21 ms p50 on a 10K-token JSON result) and runs entirely locally.

With 77K+ GitHub stars and 6K forks, Headroom has become the standard context compression layer for the coding agent ecosystem, compatible with 16+ agents out of the box.

Key Capabilities

Headroom routes content through a ContentRouter that detects the type and applies the right compression strategy. SmartCrusher handles JSON arrays and nested objects with deterministic, schema-preserving compression — keeping error items, statistical outliers, and first/last boundaries. CodeCompressor parses syntax trees for eight languages (Python, JS/TS, Go, Rust, Java, C/C++, C#, PHP). Kompress-v2-base is a custom model trained on agentic traces for prose and documentation.

Live-zone compression compresses only new content (fresh tool output) so the earlier prompt prefix stays byte-identical, maximizing provider KV-cache hits. CacheAligner flags volatile content that would break the cache prefix without rewriting prompts. CCR (reversible compression) caches originals locally — the model can call headroom_retrieve to get the full text when needed.

Cross-agent memory provides one shared store across Claude, Codex, Gemini, and Grok with automatic deduplication. headroom learn mines failed sessions and writes corrections to CLAUDE.local.md or AGENTS.md.

Real-world benchmarks: code search 100 results at 21% token retention, SRE incident debugging at 57%, codebase exploration at 42%, GitHub issue triage at 30%, log dump 10,144 → 1,260 tokens with the FATAL line preserved.

Integration

Proxy mode requires zero code changes — headroom proxy --port 8787 and point your agent’s base URL at it. Agent wrap mode: headroom wrap <agent> starts the proxy and launches the agent through it; headroom unwrap reverses it. Supports Claude Code, Codex, Grok CLI, Aider, Copilot CLI, VS Code Copilot, OpenClaw, OpenCode, Cline, Continue, Goose, OpenHands, and more. MCP server exposes headroom_compress, headroom_retrieve, and headroom_stats tools. Library mode provides compress(messages, model=...) for Python and TypeScript. SDK integrations for Anthropic, OpenAI, Vercel AI, LiteLLM, LangChain, Agno, and Strands. Python 3.10+ required, npm package for TypeScript SDK. Apache 2.0 licensed.

Similar Agents