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.
Python agentaianthropicclaude-codecompressioncontext-engineeringcontext-windowcursorfastapilangchainllmmcpopenaiprompt-engineeringproxypythonragtoken-optimizationtokenstypescript
Disable CacheAligner: it inflates tokens and breaks prefix caching
chopratejas07d278a756dc
diff --git a/headroom/proxy/server.py b/headroom/proxy/server.pyindex 98064f195..f2c17e992 100644--- a/headroom/proxy/server.py+++ b/headroom/proxy/server.py@@ -1541,7 +1541,7 @@ class HeadroomProxy:if config.mode == "token_headroom":router_config.protect_recent_reads_fraction = 0.3transforms = [- CacheAligner(CacheAlignerConfig(enabled=True)),+ CacheAligner(CacheAlignerConfig(enabled=False)),ContentRouter(router_config),context_manager,]@@ -1549,7 +1549,7 @@ class HeadroomProxy:else:# Legacy mode: sequential pipelinetransforms = [- CacheAligner(CacheAlignerConfig(enabled=True)),+ CacheAligner(CacheAlignerConfig(enabled=False)),SmartCrusher(SmartCrusherConfig( # type: ignore[arg-type]enabled=True,