Skip to content

3.6 Agent2Agent (A2A) Protocol, Agent Cards & Remote Streaming

1. Key Concept Definitions: The Agent2Agent (A2A) Interoperability Stack

Section titled “1. Key Concept Definitions: The Agent2Agent (A2A) Interoperability Stack”

In enterprise architectures, MCP and A2A are complementary layers—review these five foundational A2A building blocks:

1. MCP (Tools) vs. A2A (Peers)
MCP connects an agent to a deterministic, stateless function or database query. A2A connects peer agents across team, framework, or company boundaries where the remote agent has its own opaque reasoning loop and state.
2. A2A Agent Card (/.well-known/agent.json)
The machine-readable JSON contract published by every A2A server (and indexed in Agent Registry) declaring its skills, capabilities (streaming, pushNotifications), modalities, and auth schemes.
3. Task Lifecycle & SSE Streaming
Tracks stateful work units (taskId + contextId) across submitted -> working -> completed. When capabilities.streaming=true, streams live TaskStatusUpdateEvent and TaskArtifactUpdateEvent over SSE.
4. Push Webhooks & input-required
For multi-hour disconnected tasks, the server POSTs updates to a PushNotificationConfig webhook URL. If the remote agent needs missing user data mid-task, it pauses in state input-required.
5. ADK RemoteA2aAgent & to_a2a()
RemoteA2aAgent wraps an external A2A endpoint so an ADK coordinator can delegate to it like a local sub-agent. to_a2a(agent) exposes your ADK agent as an A2A-compliant server!

2. Interactive A2A Lifecycle & Agent Card Explorer

Section titled “2. Interactive A2A Lifecycle & Agent Card Explorer”

Switch between the 3 A2A Collaboration Modes below and click the 4 stages to trace Agent Card Discovery, SSE Streaming (SendStreamingMessage), and Async Push Notifications + input-required:

Stage 1 / 4
1. Discovery URI/.well-known/agent.json2. Capabilitiesstreaming / push flags3. Skills & Modesskills + Input/Output4. ADK BindingRemoteA2aAgent / to_a2a
STAGE 1: STANDARD DISCOVERY URI
1. Fetching the /.well-known/agent.json Agent Card
Protocol Mechanism
The Client Agent discovers the Remote Agent via Agent Registry or by fetching its public /.well-known/agent.json metadata document.
Core Architecture Rule
The Agent Card exposes WHAT the remote agent can do (skills, auth, URL) without exposing its internal prompts, code, or private tools!

3. Architectural Comparison: MCP (Tools) vs. A2A (Agents)

Section titled “3. Architectural Comparison: MCP (Tools) vs. A2A (Agents)”

Compare when to use Model Context Protocol (MCP) versus Agent2Agent (A2A) in a distributed enterprise system:

Architectural Dimension Model Context Protocol (MCP) Agent2Agent (A2A) Protocol
Relationship Model Agent-to-Tool / Resource (Caller invokes a deterministic function or database query). Agent-to-Agent (Peer-to-Peer) (Client delegates a goal to an autonomous, reasoning agent).
State & Reasoning Stateless & Deterministic: Fixed input schema (JSON Schema) -> predictable function execution -> direct output. Stateful & Autonomous: Remote agent plans, loops, calls its own private tools, and tracks multi-turn Task state.
Discovery Mechanism tools/list returns function names, descriptions, and strict parameter JSON schemas. Agent Card (/.well-known/agent.json) or Agent Registry lists high-level skills, natural-language examples, and capabilities.
Communication Primitives tools/list, tools/call, resources/read, prompts/get. Task (submitted, working, input-required, completed), Message, Part (TextPart, FilePart, DataPart), Artifact.
Primary Architectural Trigger “Query AlloyDB/BigQuery,” “invoke a deterministic REST/SQL function,” “share pooled database tools.” “Collaborate with a partner/cross-department agent,” “opaque internal reasoning,” “multi-turn negotiation (input-required).”

4. Anatomy of an A2A Agent Card & Real-World Deep Dive

Section titled “4. Anatomy of an A2A Agent Card & Real-World Deep Dive”

Review the core fields inside an A2A Agent Card and the two ADK integration helpers (RemoteA2aAgent and to_a2a()):

Agent Card / ADK Field Expected Content / Type Runtime Purpose Core Architecture Rule
name & description str Human- and LLM-readable identity and summary of the remote agent’s purpose. Used by parent orchestrators during discovery and routing.
url & version str (HTTPS endpoint + semantic version) Specifies where to send A2A JSON-RPC / HTTP requests and tracks contract versions. Managed in Agent Registry to deprecate legacy versions safely.
capabilities Object (streaming: bool, pushNotifications: bool) Declares whether the server supports SSE streaming (message/stream) and async webhooks. Always check capabilities before attempting SSE or webhook registration!
skills List of Skill objects (id, name, description, tags, examples) Describes specific tasks the agent can perform and sample utterances. Distinct, well-scoped skills prevent orchestrator misrouting across partner agents.
defaultInputModes / defaultOutputModes List of MIME types (text/plain, application/json, application/pdf) Negotiates supported content modalities (TextPart, FilePart, DataPart). Prevents a client from sending a PDF or audio file to a text-only remote agent.
authentication / securitySchemes OAuth 2.0, OIDC, API Key, or mTLS schema Tells the Client Agent how to authenticate when invoking the A2A endpoint. Enforced at the perimeter via Agent Gateway and Agent Identity.
ADK RemoteA2aAgent RemoteA2aAgent(name, description, agent_card=...) Wraps an external A2A server so an ADK coordinator can use it just like a local sub-agent! Primary way for an ADK agent to consume a remote agent built in another framework.
ADK to_a2a(agent) ADK server helper function Exposes an existing ADK agent as an A2A-compliant server with an auto-generated Agent Card. Fastest way to publish your ADK agent for cross-team A2A consumption!

5. Real-World Deep Dive: A2A Task Resumption & Streaming Mechanics

Section titled “5. Real-World Deep Dive: A2A Task Resumption & Streaming Mechanics”
Architect Question How It Works Under the Hood in Production
“When a remote A2A agent pauses in state input-required (because it needs the customer’s parcel zoning number), how does the Client Agent know what question to ask and how to resume?” Status Message + Reusing taskId & contextId: When transitioning to input-required, the Remote Agent attaches a Message (containing a TextPart or structured DataPart explaining what field is missing) inside the TaskStatus. The Client Agent obtains that info (from its own state or by prompting the human user) and sends a follow-up SendMessage carrying the exact same taskId and contextId so the Remote Agent continues right where it paused!
“What is the difference between an A2A Message and an A2A Artifact?” Conversation Turn vs. Task Deliverable: A Message represents conversational dialogue, instructions, clarifications, or status thoughts exchanged between the Client Agent and Remote Agent. An Artifact represents the formal output deliverable produced by the Task (such as a generated PDF appraisal certificate, a compiled code file, or a final structured JSON report) streamed via TaskArtifactUpdateEvent.
“When should we use SSE (SendStreamingMessage) vs. Push Notification Webhooks (PushNotificationConfig)?” Connected Seconds/Minutes vs. Disconnected Hours/Days: Use SSE (message/stream) when a user or orchestrator is actively connected and waiting for real-time progress updates over seconds or a couple of minutes. Use Push Notification Webhooks when a task takes hours or days (like physical inspections or batch settlements) so neither agent has to hold an open HTTP socket!