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(proxy): add same-origin check to /v1/retrieve/tool_call (#3955)

Satya Bharadwaj2297b5059f27
diff --git a/headroom/proxy/server.py b/headroom/proxy/server.py
index 27e4b4164..c9e8016bf 100644
--- a/headroom/proxy/server.py
+++ b/headroom/proxy/server.py
@@ -5928,7 +5928,10 @@ def create_app(config: ProxyConfig | None = None) -> FastAPI:
)
# CCR Tool Call Handler - for agent frameworks to call when LLM uses headroom_retrieve
- @app.post("/v1/retrieve/tool_call", dependencies=[Depends(_require_loopback)])
+ @app.post(
+ "/v1/retrieve/tool_call",
+ dependencies=[Depends(_require_loopback), Depends(_require_same_origin)],
+ )
async def ccr_handle_tool_call(request: Request):
"""Handle a CCR tool call from an LLM response.
diff --git a/tests/test_proxy_loopback_gating.py b/tests/test_proxy_loopback_gating.py
index 9db086a0b..1e76430e1 100644
--- a/tests/test_proxy_loopback_gating.py
+++ b/tests/test_proxy_loopback_gating.py
@@ -134,6 +134,7 @@ CSRF_GUARDED = [
"/stats/reset",
"/cache/clear",
"/v1/retrieve",
+ "/v1/retrieve/tool_call",
"/v1/telemetry/import",
"/admin/runtime-env",
]