10. Agent Communication Protocols
A2A Architecture, Discovery and Delegation
A2A architecture centers on client and remote agents, discoverable agent cards (often via a directory), and a task lifecycle with messages, streaming or polling, and artifacts. Discovery resolves and matches skills under trust rules; delegation submits work, handles input-required pauses, and completes, fails, or cancels with clear states. Master these pieces before wiring MCP and A2A together in production.
What you will learn
- Draw client, directory, remote agent, and task roles
- Explain agent-card discovery and skill matching
- Describe task states from submitted to completed/failed
- Design timeouts, input-required, and cancel paths
- Answer interview questions with short, solid answers
Definition
A2A architecture is the role and state model for peer collaboration: a client agent finds a remote agent through an agent card (directly or via a directory), authenticates, submits a task with message parts, observes progress, may supply more input, and collects artifacts β or handles failure and cancellation.
This lesson deepens the A2A overview into discovery mechanics and the delegation lifecycle you will implement or integrate.
Introduction
This lesson (#6 in Agent Communication Protocols) follows Agent-to-Agent (A2A) Protocol. You know why peers exist; now learn how discovery and tasks are structured.
Next: MCP vs A2A and Interoperability β using both contracts in one system.
Roles
- Client agent - owns the user goal and initiates delegation
- Remote agent - advertises skills and executes accepted tasks
- Directory / registry - optional index of agent cards
- Task - durable unit of work with state and history
- User / HITL - may answer input-required or approve send
Agent cards
- Identity - name, provider, version, endpoint
- Skills - what the agent claims it can do
- Auth schemes - how clients must authenticate
- Capabilities - streaming, push notifications, modalities
- Cards are advertisements β still require trust policy
Discovery
Discovery without trust is how you call the wrong peer.
- Resolve - well-known URL, registry query, or curated catalog
- Parse card - skills, auth, endpoints
- Match - skill fit, modality, cost, latency expectations
- Trust - org allowlist, signed cards, mutual TLS where required
- Cache cards with TTL; refresh on version changes
Delegation lifecycle
Treat task state as the source of truth between peers.
- Submitted - client creates the task with initial messages
- Working - remote agent progresses; client streams or polls
- Input-required - remote needs clarification or human data
- Completed - artifacts ready for the client plan
- Failed / canceled - terminal outcomes with reasons
- Always define timeouts and cancel semantics
Messages and artifacts
- Messages carry parts: text, files, structured data
- Artifacts are deliverables attached to task completion
- Keep PII out of parts unless policy allows
- Validate artifact types and sizes on the client
- Correlate ids across client logs and remote traces
Streaming vs polling
- Streaming - low latency updates for interactive UX
- Polling - simpler ops behind firewalls and queues
- Push notifications - optional for long background tasks
- Clients must handle reconnect and duplicate events
Failure modes
- Trusting unsigned cards from open registries
- No input-required handling β tasks stuck forever
- Missing cancel when the user abandons the goal
- Oversized message parts blowing memory or cost
- Skill mismatch β remote accepts then fails late
Program / implementation notes
Model Task with id, state, messages[], artifacts[]. Implement discover(cardUrl), submitTask, getTask, cancelTask. Add a client-side timeout that cancels. Log every state transition.
- Prototype input-required with a fake clarify turn
- Next: MCP vs A2A and Interoperability
Advantages and limitations
- Advantage: explicit states beat opaque RPC for long work
- Advantage: cards enable marketplace-style discovery
- Advantage: input-required supports human-in-the-loop cleanly
- Limitation: distributed state is harder to debug
- Limitation: directories can become trust and spam problems
- Limitation: not needed for in-process multi-agent crews
Key points
- Architecture: client, optional directory, remote agent, task.
- Agent cards advertise skills and auth; policy still decides trust.
- Discovery: resolve β parse β match β allowlist.
- Delegation states: submitted, working, input-required, completed, failed/canceled.
- Messages carry parts; artifacts are deliverables.
- Timeouts and cancel are mandatory for remote work.
FAQs
Do you need a public directory?
No. Many enterprises use a private catalog or hard-configured card URLs. Directories help when many peers must be discovered dynamically.
What is input-required?
A task state where the remote agent pauses for more information from the client or a human before it can continue.
Streaming or polling?
Prefer streaming for interactive UX when networks allow; polling is fine for batch and restrictive networks. Support cancel in both.
How is this different from a job queue?
Queues move work inside your system. A2A tasks cross agent/product boundaries with negotiated skills, auth, and message/artifact contracts.
Interview questions
- What are the main A2A architectural roles?
Answer A client agent, a remote agent, an optional directory of agent cards, and a stateful task that carries messages and artifacts.
- What does an agent card contain?
Answer Identity, endpoint, skills, auth requirements, and capability flags such as streaming β used for discovery and matching.
- How does discovery work?
Answer Resolve a card (URL or registry), parse skills/auth, match to the goal, then admit the peer only if trust/allowlist policy passes.
- Name key task lifecycle states.
Answer Submitted, working, input-required, completed, and failed or canceled β with timeouts and cancel support.
- Why is input-required important?
Answer It lets remote agents pause for clarification or human data instead of guessing or failing silently on incomplete tasks.
- How do you harden delegation?
Answer Allowlist peers, authenticate, minimize payload data, validate artifacts, set timeouts, support cancel, and HITL high-stakes sends.
Related topics
Practice task
Complete each numbered practice step in a notebook or doc before opening the next lesson.
- Draft an agent card for a βPDF contract extractβ specialist (skills + auth).
- Write the task state diagram including input-required and cancel.
- List three discovery trust checks before calling a new peer.
- Define timeout and polling interval for a 10-minute remote job.
- Answer interview questions 1, 3, and 4 in two sentences each.