Skip to main content

Module a2a_client

Module a2a_client 

Expand description

A2A outbound client (caller role): the a2a_* tools that delegate tasks to remote A2A-compliant agents.

Lives in zeroclaw-tools as a sibling to channel_room / http_request / git_forge, so runtime tool registration depends only on zeroclaw-tools (the gateway stays the inbound/server edge). The A2A wire types are shared with the inbound surface via zeroclaw_api::a2a_wire.

Per the A2ATool RFC: no copied peer Vec is stored in the client or tool handle. Peer definitions, credentials, and security policy resolve from canonical live Config at call time. The Agent Card cache is derived data keyed by endpoint, invalidated when the endpoint changes.

Structs§

A2aCancelTool
a2a_cancel — cancel an in-flight task.
A2aDiscoverTool
a2a_discover — list available peer agents and their capabilities.
A2aGetTaskTool
a2a_get_task — retrieve the state/artifacts of an in-flight task.
A2aHttpClient
Outbound A2A HTTP client. Holds only the reqwest client and the live config handle — no peer list copy. Constructed once, shared by all a2a_* tools behind an Arc.
A2aSendTool
a2a_send — delegate a task to a peer agent (blocking on the result).
RouteHandle
A cached route for an in-flight task: the RPC URL and tenant that created the task. Stored under the composite key (peer, agent, task_id) by send_message and reused by get_task/cancel so a task’s lifecycle stays on one endpoint — a follow-up call cannot accidentally route to a different agent/interface on an aggregate card. The peer and agent are carried in the cache key; rpc_url and tenant are the payload needed to repeat the call on the same endpoint. inserted_at records when the route was cached so the bounded cache can evict the oldest entry when it reaches capacity (abandoned in-flight routes must not grow without limit).

Functions§

shared_a2a_route_cache
The process-wide shared RouteCache for the outbound A2A client. Tool-set reassembly (every process_message turn and every agent::run invocation constructs a fresh A2aHttpClient) must not drop the route authority of an in-flight task — a SendMessage in one turn that tells the model to poll later must be reachable by GetTask/CancelTask in a later turn. The cache is keyed by (peer, agent, task_id), so independent peer/agent/task lifecycles do not collide. Daemon restart (process exit) naturally clears it — orphaned routes are stale after a restart.

Type Aliases§

RouteCache
Shared task-route state that survives tool-set reassembly across process_message turns. A SendMessage stores the selected endpoint here; a later GetTask/CancelTask (in a different turn, with a fresh A2aHttpClient) looks it up by (peer, agent, task_id). The Arc ensures all turns in the same daemon process share one instance. Daemon restart naturally clears it (orphaned routes are stale after a restart).