Agent systems and standards · Chapter 2 of 8
A2A: agents that delegate to agents
How one agent finds another through its Agent Card and hands it a task it can follow to the end.
Goals
- Read the Payments agent's Agent Card.To do
- Follow a task from WORKING through INPUT_REQUIRED to COMPLETED.To do
- Reply to a task id that is not yours and see it rejected.To do
- Put the exchange in order.To do
Step 1 of 4: The read
A peer, not a tool
A2A (Agent2Agent, protocol 1.0) connects agents that different parties run. In the previous chapter the support agent called tools on an MCP server: functions with a schema, run exactly as called. Over A2A it hands work to another agent, which decides how to do it with its own model, tools and memory. The caller sees only the task and its results.
The Agent Card
Each A2A server has an Agent Card. A public agent serves it at /.well-known/agent-card.json, where anyone can read it without a credential. It names the agent and its skills, lists its interfaces (URL, binding such as JSONRPC, protocol version), says whether it can stream, and declares how to authenticate, here a bearer token per merchant. Each request carries an A2A-Version header; a server refuses a version its card does not list (error -32009).
Messages, tasks and artifacts
The client calls SendMessage with a message made of parts: text for the other agent's model, and data parts with a media type for values it can rely on, such as the order id and the amount. The answer is a message or, for work that takes time, a task: an id, a contextId that groups a conversation, and a state such as TASK_STATE_WORKING, INPUT_REQUIRED or COMPLETED. Results arrive as artifacts on the task, apart from the chat.
INPUT_REQUIRED pauses the task until the client answers. The answer is a new message that names the same taskId and contextId. The server keeps each merchant's tasks apart: a reply naming a task this merchant does not own gets -32001, task not found, and nothing runs.
Streaming or polling
With SendStreamingMessage the server pushes server-sent events: the task first, then status and artifact updates, until the task pauses or ends. Without streaming, SendMessage answers when the task pauses or ends; with returnImmediately it answers at once, and the client polls GetTask.
What you do here
Halden's support agent and the Payments agent both run the official A2A JavaScript SDK (@a2a-js/sdk 1.3.0) in this page, each driven by a scripted LangChain model. Read the card, follow the refund task through its states and answer its question yourself. Then turn on Intercept and point your reply at another merchant's task. An optional step shows the Payments agent reaching its ledger over MCP, where MCP's input_required becomes the A2A task's INPUT_REQUIRED.
Step 2 of 4: Try it: A task across a border
A task across a border
Three steps, one action each, then two optional ones. The diagram under the steps has one column per party and one row per message, from the top down. The thick dashed line is the organisation boundary.
Mode:RealSimulatedReal: the A2A JavaScript SDK (@a2a-js/sdk 1.3.0, A2A 1.0), client and server, and the MCP SDK in the optional A2A with MCP step, run in this page. Simulated: the agents' decisions are scripted unless you connect a model, the payments are simulated, and the data is fictional.
Step 3 of 4: Check
Check
Put the A2A exchange for the refund in order.
Drag the items, or use the arrow buttons, to put them in order.
- Position 1: SendMessage with the refund request.
- Position 2: GET the Agent Card.
- Position 3: Task in TASK_STATE_COMPLETED, with the refund receipt as an artifact.
- Position 4: SendMessage with the answer, on the same task.
- Position 5: Task in TASK_STATE_INPUT_REQUIRED.
- Position 6: Task in TASK_STATE_WORKING.
Step 4 of 4: What you can do now
What you can do now
- Read an Agent Card and choose a skill and an interface.
- Send a message and follow a task's states to its artifacts, by stream or by polling.
- Answer a task in INPUT_REQUIRED with a reply on the same taskId and contextId.
- Explain when to use A2A rather than MCP.