Headroom is a library, proxy, and MCP server that compresses tool outputs, logs, files, retrieval chunks, and conversation history before they reach a language model. It helps coding agents use fewer context tokens while keeping the original content available locally when needed. Its catalogue add-ons support using Headroom with agent workflows.
Borrowing it
Nothing to install: this file belongs to headroomlabs-ai/headroom. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/headroomlabs-ai/headroom/main/AGENTS.mdgit clone --depth 1 https://github.com/headroomlabs-ai/headroomWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/instructions/headroomlabs-ai/headroom/agents-md)<a href="https://agentmods.dev/instructions/headroomlabs-ai/headroom/agents-md"><img src="https://agentmods.dev/badge/instructions/headroomlabs-ai/headroom/agents-md/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/instructions/headroomlabs-ai/headroom/agents-md"><img src="https://agentmods.dev/badge/instructions/headroomlabs-ai/headroom/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00946 | $0.00946 |
| Opus 5.5 | $0.00378 | $0.00378 |
| Sonnet 5.5 | $0.00189 | $0.00189 |
| Haiku 4.5 | $0.00095 | $0.00095 |
Grade A, and why
headroom AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 25d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 42 lines — stays where its author put it; the contents beside it link to each section on GitHub.
AGENTS.md
If you landed here to use Headroom in an app
The PyPI package is headroom-ai; the import and the CLI are headroom.
pip install headroom-ai
from headroom import compress
result = compress(messages, model="gpt-4o") # OpenAI or Anthropic message dicts
# send result.messages instead of messages; log result.tokens_before / tokens_after / tokens_saved
In-process, no API key, no model download. HEADROOM_OFFLINE=1 makes the run
zero-network (no update check, no model or pricing-table downloads, no beacon).
Verify without a provider key:
HEADROOM_OFFLINE=1 python -c "from headroom import compress; log='\n'.join(f'INFO step {i} ok' for i in range(3000))+'\nFATAL disk full'; r=compress([{'role':'user','content':'What failed?'},{'role':'assistant','content':None,'tool_calls':[{'id':'c1','type':'function','function':{'name':'logs','arguments':'{}'}}]},{'role':'tool','tool_call_id':'c1','content':log}], model='gpt-4o'); print(r.tokens_before, '->', r.tokens_after, 'FATAL kept:', 'FATAL' in str(r.messages))"
- FastAPI example: https://docs.headroomlabs.ai/docs/fastapi
- Full docs index for agents: https://docs.headroomlabs.ai/llms.txt (hand-curated subset:
llms.txtin this repo) - Coding agents (Claude Code, Codex, Cursor, Copilot):
uv tool install --python 3.13 "headroom-ai[all]"thenheadroom wrap claude headroom.integrations.asgi.CompressionMiddlewareis for apps that serve/v1/chat/completions-style routes, not for an app that calls a provider; usecompress()for that- Canonical repo: https://github.com/headroomlabs-ai/headroom.
github.com/chopratejas/headroomredirects here; there is noheadroom-sdkorg. The PyPI distribution namedheadroomis a different project.
If you are changing this repo
- Layout: Python package in
headroom/, Rust core and PyO3 extension incrates/(built by maturin), TypeScript SDK insdk/typescript/, docs site (Next.js + Fumadocs) indocs/content/docs/, agent plugins inplugins/, examples inexamples/. - Setup:
uv sync --extra devandmake install-git-hooks(pre-commit, commitlint, pre-push). Python checks:uv run ruff check .,uv run ruff format .,uv run pytest. Rust checks:make ci-precheck-rust. All gates:make ci-precheck. SeeCONTRIBUTING.md. - Commits and PR titles are Conventional Commits (
feat:,fix:,docs:, ...). Never editCHANGELOG.md; release-please writes it from PR titles. - Every external PR needs a "Real behavior proof" section (setup, exact commands, observed output, what was not tested). Bug fixes need a test that fails before the fix.
- One docs site:
docs/, deployed by Vercel to docs.headroomlabs.ai.wiki/and thegh-pagesbranch are not published; do not add content there. - Public API examples in
README.md,llms.txt,AGENTS.mdanddocs/must use names that exist inheadroom/compress.py(compress,CompressResult.messages,.tokens_before,.tokens_after,.tokens_saved,.compression_ratio,.transforms_applied). - Savings claims anywhere in the repo must match the measured table under "Proof" in
README.md: 21-57% on the four agent scenarios, 90%+ on repeated JSON arrays and log lines, little on prose. - Version-carrying files (
pyproject.toml, plugin and marketplace manifests,sdk/typescript/package.json,server.json) are kept in step byscripts/version-sync.pyand gated byscripts/verify-versions.py; add any new one to both.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 25d ago First seen · 42 lines · 946 tokens per session scan A 8c011f404da8
headroom AGENTS.md is an instructions file published in the GitHub repository headroomlabs-ai/headroom (81,156 stars, last pushed today), licensed Apache-2.0. It adds 946 tokens to every session, about $0.0038 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-05.
headroom AGENTS.md compared with instructions from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| headroom AGENTS.mdheadroomlabs-ai/headroom | Instructions file | 81k | today | Apache-2.0 | A | 946 | Codex, OpenCode |
| vscode buildNext.instructions.mdmicrosoft/vscode | Instructions file | 196k | today | MIT | A | 9,887 | GitHub Copilot |
| next.js AGENTS.mdvercel/next.js | Instructions file | 144k | today | MIT | A | 7,230 | Codex, OpenCode |
| vscode oss-third-party-notices.instructions.mdmicrosoft/vscode | Instructions file | 196k | today | MIT | A | 5,685 | GitHub Copilot |
| langchain AGENTS.mdlangchain-ai/langchain | Instructions file | 150k | yesterday | MIT | A | 4,680 | Codex, OpenCode |
| vscode copilot-instructions.mdmicrosoft/vscode | Instructions file | 196k | today | MIT | A | 3,303 | GitHub Copilot |
| deepseek-harness AGENTS.mddeepseek-ai/deepseek-harness | Instructions file | 289k | 2d ago | MIT | A | 4,393 | Codex, OpenCode |