From 453a7ae22a24e7a3f46ad237cdfdd81ddaa96741 Mon Sep 17 00:00:00 2001 From: Renn F Date: Sat, 2 May 2026 05:06:32 +0200 Subject: [PATCH] fix(orchestrator): forward agent UUID (not slug) as ROBOCO_AGENT_ID to MCP env Gateway v2 endpoints declare X-Agent-ID as Annotated[UUID, Header(...)]. The MCP servers (flow_server, do_server) read os.environ['ROBOCO_AGENT_ID'] verbatim and put it in the header. We were exporting the slug ('main-pm', 'be-dev-1', ...) so every gateway call from a containerized agent 422'd on header UUID parse. Resolve to UUID via AGENT_UUIDS lookup in seeds/initial_data.py. Surfaced by the new 422 logger (de54c3b) during NAS smoke. --- roboco/runtime/orchestrator.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/roboco/runtime/orchestrator.py b/roboco/runtime/orchestrator.py index 075f9eb3..c60d3d5e 100644 --- a/roboco/runtime/orchestrator.py +++ b/roboco/runtime/orchestrator.py @@ -1740,11 +1740,17 @@ class AgentOrchestrator: api_url = f"http://127.0.0.1:{settings.port}" agent_role = get_agent_role(agent_id) or "" + # Gateway v2 endpoints declare X-Agent-ID as Annotated[UUID, Header(...)], + # so the MCP server has to forward the agent's UUID — not the slug — or + # every gateway call 422s on header parse. Resolve via AGENT_UUIDS map; + # if the slug isn't in the map (custom agents), fall back to the slug + # and let the API surface the unknown-agent error. + agent_uuid = AGENT_UUIDS.get(agent_id, agent_id) mcp_env: dict[str, str] = { "ROBOCO_API_URL": api_url, "ROBOCO_ORCHESTRATOR_URL": api_url, - "ROBOCO_AGENT_ID": agent_id, + "ROBOCO_AGENT_ID": agent_uuid, "ROBOCO_AGENT_ROLE": agent_role, }