Skip to content

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.

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.py
index 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 calls
buffered_chunks: list[bytes] = []
full_sse_data = ""
+ parsed_response = None # Set by memory block; used by CCR + prefix tracker
try:
async with contextlib.aclosing(upstream_response) as response: