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.

style: ruff format compute_turn_id body

Garmd88c1abde961
diff --git a/headroom/proxy/helpers.py b/headroom/proxy/helpers.py
index 3ccbe0878..c50834ac7 100644
--- a/headroom/proxy/helpers.py
+++ b/headroom/proxy/helpers.py
@@ -310,12 +310,10 @@ def compute_turn_id(
break
if isinstance(content, list):
has_text = any(
- isinstance(block, dict) and block.get("type") == "text"
- for block in content
+ isinstance(block, dict) and block.get("type") == "text" for block in content
)
has_tool_result = any(
- isinstance(block, dict) and block.get("type") == "tool_result"
- for block in content
+ isinstance(block, dict) and block.get("type") == "tool_result" for block in content
)
# An agent-loop continuation carries tool_result blocks; only a
# fresh user turn is text-only.