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
style: ruff format compute_turn_id body
Garmd88c1abde961
diff --git a/headroom/proxy/helpers.py b/headroom/proxy/helpers.pyindex 3ccbe0878..c50834ac7 100644--- a/headroom/proxy/helpers.py+++ b/headroom/proxy/helpers.py@@ -310,12 +310,10 @@ def compute_turn_id(breakif 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.