headroomlabs-ai/headroom

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.

What it solves

Headroom reduces the number of tokens sent to and received from LLMs, lowering costs and latency for AI agents. It specifically targets the "ceremony" and repetitive data found in tool outputs, logs, RAG chunks, and conversation history that often bloat agent prompts without adding unique value.

How it works

Headroom acts as a local compression layer between the agent and the LLM provider. It uses a ContentRouter to detect the type of data and apply the appropriate compression method:

  • SmartCrusher: Handles JSON data using field-variance statistics to keep critical values while removing repetitive patterns.
  • CodeCompressor: Uses AST-aware compression for multiple programming languages.
  • Kompress-v2-base: A specialized HuggingFace model for compressing prose and text.
  • CacheAligner: Ensures volatile content doesn't break the provider's KV-cache prefix.
  • CCR (Context Compression & Retrieval): Caches original text locally, allowing the model to retrieve the full version via a tool if needed.

It can be deployed as a library (Python/TypeScript), a transparent proxy for zero-code changes, or an MCP server.

Who it’s for

Developers and power users who run coding agents (like Claude Code, Cursor, Aider) daily and want to reduce token usage, as well as developers building AI agent applications who need a way to compress large contexts across multiple agents.

Highlights

  • Broad Agent Compatibility: Supports wrapping for a wide range of tools including Claude Code, Cursor, Aider, and Copilot.
  • Cross-Agent Memory: Provides a shared memory store across different LLMs (e.g., Gemini, Grok, Claude) with automatic deduplication.
  • Output Token Reduction: Trims model responses by steering verbosity and adjusting reasoning effort for routine tasks.
  • Local Execution: Compression runs entirely on the user's machine; no prompt or file content is sent to external servers for compression.
  • headroom learn: Analyzes failed sessions to write corrections to local agent configuration files.

Related

  • Project
  • Project
  • Project
  • Project
  • Dispatch