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: move extract_user_query import out of conditional scope
matgasser4e0c5607a0bb
diff --git a/headroom/proxy/server.py b/headroom/proxy/server.pyindex a5a62c3a2..400e0da0a 100644--- a/headroom/proxy/server.py+++ b/headroom/proxy/server.py@@ -2410,10 +2410,9 @@ class HeadroomProxy:original_tokens = tokenizer.count_messages(messages)# Hook: pre_compress — let hooks modify messages before compression+ from headroom.transforms.query_echo import extract_user_queryif self.config.hooks:from headroom.hooks import CompressContext- from headroom.transforms.query_echo import extract_user_query-_hook_ctx = CompressContext(model=model,user_query=extract_user_query(messages),