Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(tools): srv-tool client sends the token as a Bearer header

sambazhu00e130f1cf5f
diff --git a/agent/src/tools/gildata_srv.py b/agent/src/tools/gildata_srv.py
index 0759c3872..a037fc1a3 100644
--- a/agent/src/tools/gildata_srv.py
+++ b/agent/src/tools/gildata_srv.py
@@ -62,7 +62,9 @@ def call_srv_tool(
if not token:
raise RuntimeError("GILDATA_TOKEN is not configured")
- url = f"{_url()}&token={token}"
+ # Token rides the Authorization header, never the URL — request
+ # exceptions embed the full URL in their message (review of #1474).
+ url = _url()
payload = {
"jsonrpc": "2.0",
"id": 1,
@@ -76,7 +78,10 @@ def call_srv_tool(
_MIN_INTERVAL_ENV, _DEFAULT_MIN_INTERVAL_S
),
json_body=payload,
- headers={"Accept": "application/json, text/event-stream"},
+ headers={
+ "Accept": "application/json, text/event-stream",
+ "Authorization": f"Bearer {token}",
+ },
timeout=timeout,
)
diff --git a/agent/tests/test_gildata_research_tools.py b/agent/tests/test_gildata_research_tools.py
index bb78d217b..20946355a 100644
--- a/agent/tests/test_gildata_research_tools.py
+++ b/agent/tests/test_gildata_research_tools.py
@@ -152,3 +152,26 @@ class TestNumericCoercion:
# NOTE: whether percent claims VERIFY against these leaves is an
# upstream grounding question (the metric pool admits analysis
# metrics only) — tracked as an upstream issue, not asserted here.
+
+
+class TestTokenTransport:
+ """The token must ride the Authorization header, never the URL."""
+
+ def test_call_srv_tool_sends_bearer_header(self, monkeypatch):
+ from unittest.mock import patch
+ from src.tools import gildata_srv
+
+ monkeypatch.setenv("GILDATA_TOKEN", "secret")
+ captured = {}
+
+ def fake_post(url, **kwargs):
+ captured["url"] = url
+ captured["headers"] = kwargs.get("headers")
+ return {"result": {"content": [{"type": "text", "text": '{"code":0,"results":[]}'}]}}
+
+ with patch.object(gildata_srv, "throttled_post_json", side_effect=fake_post):
+ gildata_srv.call_srv_tool("MacroIndustryData", "GDP")
+
+ assert "token=" not in captured["url"]
+ assert captured["headers"]["Authorization"] == "Bearer secret"
+ assert captured["headers"]["Accept"] == "application/json, text/event-stream"