liveBook · Manning

A2A server

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

An A2A server is a service that exposes agents to network clients and handles their task execution.

An A2A server exposes agents to network clients and handles their task execution. For example, a multi-agent system can send preprocessing work to another team’s agent without rebuilding it. A2A standardizes communication over HTTP, while leaving the agent’s internal logic and framework independent. section 10.0 section 10.1.2

Unlike a local subagent, an A2A agent runs behind a server in a separate process. Its implementation may be maintained by another team and treated as a black box: the client sends work and receives results over the network. section 10.1.1

A client interacts with a server in two main exchanges:

  • Discovery: the client makes an HTTP GET request to the server’s well-known URI to retrieve AgentCards. A card describes an agent’s capabilities and reachable URI. section 10.1.2
  • Task execution: the client sends instructions using A2A’s JSON-RPC communication. The server returns the result or an error; long-running tasks can also support streaming updates or completion notifications. section 10.1.2

A task-initiating Message typically contains a text Part with instructions. The server hosts and maintains stateful Task objects, including execution status; a completed Task can contain Artifacts with results. For a quick interaction, an agent can respond with a Message instead of a Task. section 10.1.3

Figure 10.6 A sequence diagram of the task lifecycle, overlaid with the A2A elements

Follow the task lifecycle and the A2A elements exchanged between client and server. section 10.1.3

To expose an LLMAgent with FastAPI and the a2a-sdk:

  • Create a Python application, build an LLMAgent, and wrap it in an LLMAgentA2AExecutor. section 10.3 section 10.3.2
  • Create an AgentCard and a FastAPI application. Create a DefaultRequestHandler, use SDK helpers to add the required routes, and launch the application. section 10.3.2

Remote hailstone agent

A coordinator discovers a locally launched server through A2AAgentSpec.from_url and adds the resulting spec to its agent registry. It then asks the remote agent to compute the hailstone sequence starting at 8; the returned sequence is 8, 4, 2, 1. section 10.3.2

The basic LLMAgentA2AExecutor does not handle streaming or the server-side input-required workflow. A separate StreamingLLMAgentA2AExecutor enables streaming updates; supporting input-required would require the agent to continue an ongoing rollout. The client and server integrations also do not use context_id for multi-turn context sharing. section 10.4.2

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

How deep it goes
Explains discovery, task lifecycle and SDK setup steps, but defers server construction code.
Examples
Demonstrates a coordinator discovering a hailstone agent and requesting the sequence starting at 8.
What you can do after
Operate/configure an A2A server using FastAPI and a2a-sdk setup steps.
How it connects
Connects AgentCards, JSON-RPC, task state, artifacts and local subagents.

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.