Agents that discover each other
The Agent-to-Agent (A2A) protocol is a standardized framework letting AI agents collaborate, share context, and invoke capabilities securely across different vendors and platforms. Its advantages: cross-vendor collaboration, flexible model selection (each agent independently chooses its LLM — unlike MCP's single-LLM connection), and integrated authentication.
Key concept · Agent Skills and the Agent Card
An agent skill is a specific capability the agent performs — with an id, name, description, tags, examples, and input/output modes. The Agent Card is the agent's "digital business card": a structured document giving its identity (name, description, version), endpoint URL, capabilities (streaming, push notifications), default input/output modes, its list of skills, and authentication requirements. Publishing the card is what lets other agents/clients discover the agent and interact appropriately.
The discovery flow: an agent defines skills and publishes its card → others discover it automatically → requests route to the right skill → responses return in supported formats. A routing agent can retrieve several cards and orchestrate a multi-agent workflow (e.g. one agent's title feeds another's outline).
Serving an A2A agent
The Agent Executor bridges the A2A protocol and the agent's business logic — it processes incoming requests, generates responses, and (optionally) handles cancellation. An A2A server hosts it and routes events back to callers.
Key concept · Execute, cancel, and the event queue
The executor exposes two operations: Execute (reads request details from the RequestContext, runs the logic, and places results on the EventQueue) and Cancel (task cancellation, which simple agents may not support). A routing mechanism delivers the queued events back to the requester — a standardized contract every client and agent can rely on.
Consuming a remote agent
An A2A client connects through a structured flow: get the server's base URL → fetch the Agent Card from its well-known endpoint → initialize the client with the card → send messages. Each request carries a unique id (idempotency).
| Kind | Behavior |
|---|---|
| Non-streaming request | Send a message, wait for the complete response — simple, single-response interactions. |
| Streaming request | Receive incremental partial results asynchronously — long-running tasks, live updates. |
| Direct message response | Immediate text or structured content. |
| Task object response | An ongoing task; follow-up calls fetch status/results. |
Design for a dual response model — be ready for both immediate messages and task-based returns — and handle streaming asynchronously.
Chapter 15 quiz
Fourteen questions on the A2A protocol, the executor and server, and connecting a client. Answer first, then expand Show answer.
Part A · Multiple choice
What is the A2A protocol for?
- A Connecting an agent to tools
- B Standardized agent-to-agent collaboration across vendors and platforms
- C Fine-tuning models
- D Content filtering
Show answer
B. A2A connects agents to each other; MCP connects an agent to tools.
What is the Agent Card?
- A A billing statement
- B A structured discovery document describing identity, endpoint, capabilities, and skills
- C A fine-tuning dataset
- D A content filter
Show answer
B. The agent's "digital business card" for discovery.
How does A2A's model selection differ from MCP?
- A Each A2A agent independently chooses its own LLM
- B A2A forces one shared LLM
- C A2A uses no models
- D They're identical
Show answer
A. MCP scenarios rely on a single LLM connection; A2A agents each pick their own.
What bridges the A2A protocol to an agent's business logic?
- A The Agent Executor
- B The Agent Card
- C A content filter
- D A vector index
Show answer
A — the Agent Executor. It processes requests and returns responses.
Where does the executor place results for return to the client?
- A The EventQueue
- B A database
- C The Agent Card
- D The system prompt
Show answer
A — the EventQueue. A routing mechanism delivers events to the requester.
What must a client fetch before sending messages to an A2A agent?
- A The Agent Card from the server's well-known endpoint
- B A fine-tuned model
- C An API key only
- D Nothing
Show answer
A. Base URL → fetch Agent Card → initialize client → send messages.
Part B · True or false
An agent skill includes an id, name, description, tags, examples, and input/output modes.
Show answer
True. Skills are the building blocks the card advertises.
A2A responses can be either direct messages or task objects.
Show answer
True. Design for a dual response model — immediate or task-based.
All A2A agents must support task cancellation.
Show answer
False. Cancel may not be supported for simple agents.
Streaming requests deliver incremental results asynchronously.
Show answer
True. Useful for long-running tasks and real-time updates.
A routing agent can retrieve multiple Agent Cards and orchestrate a workflow across agents.
Show answer
True. e.g. one agent's title feeds another agent's outline.
Part C · Short answer
Name three of A2A's key advantages.
Show answer
Cross-vendor collaboration, flexible per-agent model selection, and integrated authentication.
Name the two operations the Agent Executor exposes.
Show answer
Execute (process the request via RequestContext, place results on the EventQueue) and Cancel.
Give the four connection steps for an A2A client.
Show answer
Get the base URL → fetch the Agent Card → initialize the client → send messages.