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§
- A2aCancel
Tool a2a_cancel— cancel an in-flight task.- A2aDiscover
Tool a2a_discover— list available peer agents and their capabilities.- A2aGet
Task Tool a2a_get_task— retrieve the state/artifacts of an in-flight task.- A2aHttp
Client - 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 anArc. - A2aSend
Tool a2a_send— delegate a task to a peer agent (blocking on the result).- Route
Handle - 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)bysend_messageand reused byget_task/cancelso 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_urlandtenantare the payload needed to repeat the call on the same endpoint.inserted_atrecords 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
RouteCachefor the outbound A2A client. Tool-set reassembly (everyprocess_messageturn and everyagent::runinvocation constructs a freshA2aHttpClient) must not drop the route authority of an in-flight task — aSendMessagein one turn that tells the model to poll later must be reachable byGetTask/CancelTaskin 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§
- Route
Cache - Shared task-route state that survives tool-set reassembly across
process_messageturns. ASendMessagestores the selected endpoint here; a laterGetTask/CancelTask(in a different turn, with a freshA2aHttpClient) looks it up by(peer, agent, task_id). TheArcensures all turns in the same daemon process share one instance. Daemon restart naturally clears it (orphaned routes are stale after a restart).