fix(a2a-tools): auth_headers on recall_memory + commit_memory (#304)

Adds auth_headers to recall_memory and commit_memory in a2a_tools.py. Fixes the #215-class auth regression for A2A memory tools. Test mocks updated to accept headers kwarg.
This commit is contained in:
Hongming Wang 2026-04-15 19:12:18 -07:00 committed by GitHub
parent f28bba0321
commit e88ae9f6d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -226,6 +226,7 @@ async def tool_commit_memory(content: str, scope: str = "LOCAL") -> str:
resp = await client.post(
f"{PLATFORM_URL}/workspaces/{WORKSPACE_ID}/memories",
json={"content": content, "scope": scope},
headers=_auth_headers_for_heartbeat(),
)
data = resp.json()
if resp.status_code in (200, 201):
@ -247,6 +248,7 @@ async def tool_recall_memory(query: str = "", scope: str = "") -> str:
resp = await client.get(
f"{PLATFORM_URL}/workspaces/{WORKSPACE_ID}/memories",
params=params,
headers=_auth_headers_for_heartbeat(),
)
data = resp.json()
if isinstance(data, list):

View File

@ -45,11 +45,11 @@ class FakeClient:
async def __aexit__(self, *args):
pass
async def post(self, url, json=None):
async def post(self, url, json=None, headers=None, **kwargs):
self.calls.append(("POST", url, json))
return FakeResponse(201, {"id": "mem-abc", "scope": json.get("scope", "LOCAL") if json else "LOCAL"})
async def get(self, url, params=None):
async def get(self, url, params=None, headers=None, **kwargs):
self.calls.append(("GET", url, params))
return FakeResponse(200, [
{"id": "mem-1", "content": "Test memory", "scope": "LOCAL"},
@ -124,7 +124,7 @@ async def test_recall_memory_empty(monkeypatch):
mcp = _load_mcp()
class EmptyClient(FakeClient):
async def get(self, url, params=None):
async def get(self, url, params=None, headers=None, **kwargs):
return FakeResponse(200, [])
monkeypatch.setattr("a2a_tools.httpx.AsyncClient", lambda **kw: EmptyClient())