# headroom

> Compresses tool outputs, logs, files and RAG chunks before they reach the LLM, so agents and apps use fewer input tokens.

- Type: agent or tool
- Field: Automation & Workflows
- Repository: https://github.com/headroomlabs-ai/headroom
- GitHub stars: 81211
- Licence: Apache-2.0
- Language: Python
- Last push: 2026-12-01
- Page: https://imutechz.in/agents/headroom

## What it is
Headroom compresses what your AI agent reads, including tool outputs, logs, RAG chunks, files and conversation history, before it reaches the model. It runs on your machine and can be used as a Python or TypeScript library, a local proxy, or a one-command wrapper for coding agents. The README reports fewer input tokens on agent scenarios and larger savings on repeated JSON and logs, with little on prose.

## Features
- compress() library call for Python and TypeScript
- Local proxy that needs no code changes
- headroom wrap for agents such as Claude Code, Codex and Cursor
- MCP server with compress, retrieve and stats tools
- Reversible compression with originals cached locally
- Cross-agent memory store

## Best for
- Cutting input tokens in LLM apps
- Wrapping coding agents without code changes
- Shrinking large JSON arrays and logs
- Reducing RAG context size

## Pros
- Compression runs locally; no content is sent elsewhere
- Original text can be retrieved on demand
- Works in-process with no API key

## Cons
- README says savings on prose are small

## Install
```
pip install headroom-ai
uv tool install --python 3.13 "headroom-ai[all]"
headroom wrap claude
```

## Usage
```
from headroom import compress

result = compress(messages, model="gpt-4o")
```

Tags: token-compression, context-engineering, llm, coding-agents, proxy, mcp, rag, python
