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: initialize parsed_response to prevent UnboundLocalError crashing all streaming responses
Tejas Chopraf65c09a835e5
diff --git a/headroom/proxy/handlers/streaming.py b/headroom/proxy/handlers/streaming.pyindex 5480d8fd6..09da2f20f 100644--- a/headroom/proxy/handlers/streaming.py+++ b/headroom/proxy/handlers/streaming.py@@ -523,6 +523,7 @@ class StreamingMixin:# For memory mode, we buffer the response to check for tool callsbuffered_chunks: list[bytes] = []full_sse_data = ""+ parsed_response = None # Set by memory block; used by CCR + prefix trackertry:async with contextlib.aclosing(upstream_response) as response: