liveBook · Manning

A2A client

As explained in Build a Multi-Agent System (from Scratch)

An A2A client is an agent or application that communicates with A2A servers to discover agents and send them tasks.

An A2A client is an agent or application that discovers remote agents and sends tasks to them through A2A servers. Standardized HTTP communication lets a multi-agent system reuse agents built with other frameworks without creating a custom API for each one. section 10.0 section 10.1.2

A client typically performs two exchanges:

  • Discover agents by requesting AgentCards from the server’s well-known URI with HTTP GET. An AgentCard describes an agent’s capabilities and where it can be reached. section 10.1.2
  • Send a task to the server and receive its result or an error. Task communication uses JSON-RPC; the protocol does not prescribe the agent’s internal logic. section 10.1.2

A task request contains a Message with one or more Parts. A Part can hold text, raw bytes, a file URI, or JSON. The server can return a stateful Task with a status and, on completion, Artifacts containing results. A client can reference a prior Task by ID; for a quick interaction, the server may respond with a Message instead. section 10.1.3

Dispatching a remote task

A client can send a text Part containing “Compute the Hailstone sequence starting at 6.” A completed Task can return an Artifact containing “6, 3, 10, 5, 16, 8, 4, 2, 1.” section 10.1.3

To make an LLMAgent a client, represent remote agents with a spec and provide a dispatch tool. UseA2AAgentTool maintains a registry of A2AAgentSpec entries, validates the tool-call arguments, and uses the official a2a-sdk to send a Message to the selected server. It converts the response into a ToolCallResult for the agent. section 10.2 section 10.2.2

Included in chapter-notebooks/ch10/ch10.ipynb #A
from llm_agents_from_scratch.a2a import UseA2AAgentTool
from llm_agents_from_scratch.data_structures import ToolCall
 
tool = UseA2AAgentTool(a2a_agents_registry={spec.name: spec}) #B
tool_call = ToolCall( #C
    tool_name="from_scratch__use_a2a_agent",
    arguments={
        "name": spec.name,
        "task": "Give me the hailstone sequence starting at 4.",
    },
)
result = await tool(tool_call=tool_call)
print(result.content)

This example registers a remote agent, creates a named task call, and awaits its result. section 10.2.2

This tool-based integration blocks until remote execution terminates, so it does not stream progress to the LLMAgent. It supports the input-required flow on the client side, but does not use context_id for multi-turn context sharing. A2A also supports streaming and push notifications for long-running tasks. section 10.4.2 section 10.1.2

How Build a Multi-Agent System (from Scratch) covers it

How deep it goes
Explains discovery, task data structures and tool-based dispatch; defers the response-conversion utility and omits client streaming.
Examples
Uses a Hailstone sequence request and a CrewAI remote agent to demonstrate task dispatch and results.
What it assumes
Assumes an existing LLMAgent and familiarity with tool-based subagent dispatch.
What you can do after
Builds a tool-based client using the a2a-sdk to send remote tasks and return tool-call results.
How it connects
Connects agent discovery and AgentCards with JSON-RPC, task lifecycles and tool calls.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Multi-Agent System (from Scratch). The section links point to the parts of the book it draws on.