TrendWhat rose on GitHub, every day at 07:30 KST · 한국어

GitHub · as of November 26, 2026 · View on GitHub →

headroomlabs-ai/headroom

AI context compression library

+776 stars in 7 days

Reduce input tokens for AI agents with a local compression tool

Imagine a coding agent reading tool outputs or logs with fewer unnecessary tokens, allowing you to get the same answer at a lower cost. Headroom is a local tool that compresses data before it reaches the LLM, ensuring prompts and file contents are not sent externally. It can be integrated into Python and TypeScript apps, as well as various coding agents.

Measured token savings

In four scenarios using actual MCP server output formats, input tokens were reduced by 21 to 57 percent. Repetitive JSON arrays or log lines are compressed by more than 90 percent, while prose sees little reduction. Accuracy evaluations on GSM8K and SQuAD v2 showed that existing performance was maintained or slightly improved.

Compression strategies by data type

ContentRouter detects content types and selects the appropriate compressor. SmartCrusher handles JSON arrays and objects, CodeCompressor processes AST-based source code, and Kompress-v2-base handles text. CacheAligner flags volatile content that could break a provider's KV-cache but does not rewrite the prompt. CCR caches the original locally so the model can retrieve the original text via headroom_retrieve when needed.

Integration methods for agents and apps

Use the library if you are constructing prompts in your own code, or use a proxy or wrapper if you are configuring agents without code changes.

  • Library In Python or TypeScript apps, call the compress(messages) function directly to compress inline. It runs within the process without requiring an API key or model download.
  • Proxy Running headroom proxy allows clients in any language to use compressed prompts without code changes. All OpenAI-compatible clients are supported.
  • Agent wrapping Commands like headroom wrap claude set up coding agents such as Claude Code, Codex, and Cursor in one step. The proxy terminates when the session ends, and you can revert using headroom unwrap.
  • MCP server Provides headroom_compress, headroom_retrieve, and headroom_stats tools for MCP clients. It also includes features for sharing memory and removing duplicates between multiple agents.

Output token reduction feature

You can also reduce the tokens in responses written by the model. It adds an instruction to answer concisely at the end of the system prompt, reducing unnecessary introductions or code re-inference. This feature is supported on Anthropic and OpenAI-compatible endpoints and is designed to maintain prompt cache hits.

Considerations before applying

Compression effects are minimal for short conversational prompts or prose-heavy tasks, so it is not recommended for those use cases. Python 3.11 or higher is required, and on x86 environments, some features are disabled if the AVX2 instruction set is missing. macOS Apple Silicon and Linux support native wheels, but Docker installation is recommended for Intel macOS. If you use SSL inspection or MITM proxies on enterprise networks, CA certificate configuration may be necessary.

Written by AI from this repository's README on November 4, 2026. For the facts, the original on GitHub is the reference.

By the numbers

GitHub trending history
6 days between Jun 19, when Trend began recording, and Nov 26, 2026 · best daily rank #4 (Oct 21)

Read from GitHub, as of November 26, 2026.

Language
Python
Topics
agent · ai · anthropic · claude-code · compression · context-engineering · context-window · cursor
Stars
80,929
Stars gained in 7 days
+776
Contributors
419
Forks
6,355
Latest release
v0.45.0 · November 22, 2026
Commits
3,834
Last commit
November 26, 2026
Open issues
136
Open pull requests
198

Related repositories

View on GitHub → · Homepage

README badge

trend.ondo.sh · GitHub daily trending #4 · October 21, 2026

The badge above shows the highest this repository has ranked on GitHub's daily trending since June 19, 2026, and the day it did. Paste the Markdown below into your README. The badge opens this page, and it updates by itself when the repository climbs higher.

[![trend.ondo.sh](https://trend.ondo.sh/github/r/headroomlabs-ai--headroom/badge.en.svg)](https://trend.ondo.sh/github/r/headroomlabs-ai--headroom/en.html)