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
fix: prevent stat inflation in compute_frozen_count, fix token estimate
chopratejas87fec30c0843
diff --git a/headroom/cache/compression_cache.py b/headroom/cache/compression_cache.pyindex 3659ef8c4..9aa7b80d0 100644--- a/headroom/cache/compression_cache.py+++ b/headroom/cache/compression_cache.py@@ -151,7 +151,7 @@ class CompressionCache:content = _extract_tool_result_content(msg)if content is not None:h = self.content_hash(content)- if self.get_compressed(h) is None:+ if h not in self._cache:breakelse:# tool_result with non-string content; treat as unstable@@ -202,5 +202,5 @@ class CompressionCache:if orig_content == comp_content:continueh = self.content_hash(orig_content)- tokens_saved = len(orig_content) - len(comp_content)+ tokens_saved = len(orig_content) // 4 - len(comp_content) // 4self.store_compressed(h, comp_content, tokens_saved=max(tokens_saved, 0))