Show HN: Headroom – Reversible context compression for LLMs(~60% cost reduction)(github.com)
github.com
Show HN: Headroom – Reversible context compression for LLMs(~60% cost reduction)
https://github.com/chopratejas/headroom
https://github.com/chopratejas/headroom
The problem: tools return huge JSON (search results, DB queries, file listings). Each response bloats context. By turn 10, you're paying for 100k+ tokens on every LLM call.
Existing solutions have a fundamental tradeoff: - Truncation: fast but you might cut data the model needs - Summarization: slow (~500ms) and still lossy - Bigger context: just delays the problem, costs more
The insight behind Headroom:
You can't know which data matters until the model tries to use it. So instead of guessing, compress aggressively AND keep a retrieval path.
Results on my workloads: - Search results (1000 items): 45k → 4.5k tokens (90%) - Agent with tools (10 calls): 100k → 15k tokens (85%) - Overhead: 1-5ms per request
Usage:
Or wrap your client: from headroom import HeadroomClient client = HeadroomClient(OpenAI())
LangChain integration is one line.
Limitations I'm aware of: - CCR adds memory overhead (LRU cache, configurable) - AST compression requires tree-sitter (~50MB) - Not battle-tested on all edge cases yet
Happy to answer questions about the compression algorithms, the retrieval mechanism, or anything else.