Building and Using A2A: A Deep Dive into Agent-to-Agent Collaboration

Last week at AGNTCon + MCPCon North America in San Jose, Google ran a hands-on workshop called “Hands-on A2A: Service Discovery and Multi-Agent Delegation.” It was led by Pedro Melendez, Sergio Villani and Sirisha Karra from Google. There were no product pitches. You got a lab environment, a set of agents, and 60 to 70 minutes to wire them together.

Pedro and Sergio also published a write-up of the same architecture on Medium, From Solo Agents to Agent Ecosystems with A2A. This post pulls the two together. I’ll walk through what the Agent2Agent (A2A) protocol is, why you might want it, and how the lab’s four agents use it to find each other, get access and hand off work.

If you want to follow along in code, everything lives in the companion GitHub repository.

The problem with the do-everything agent

Most teams start with one agent. Then someone needs it to query the finance warehouse, so a SQL connection gets added. Then an internal REST API. Then a few more pages of instructions. Before long the context window is bloated, the agent picks the wrong tool more often, and nobody is sure which credentials it holds.

Pedro and Sergio point out that real organizations don’t work this way anyway. Data and expertise are spread across teams:

  • Each business unit (finance, HR, analytics, supply chain) owns its own data and can’t hand database credentials to another team’s agent.
  • Sensitive systems sit behind zero-trust controls that expect identity checks and short-lived access tokens.
  • Teams build on different frameworks, such as Google ADK, the OpenAI Agents SDK, LangGraph or CrewAI, and nobody wants a full rewrite.

The obvious fix is to split the work across specialized agents. But that creates a new problem. Without a shared standard, every pair of agents needs its own glue code across REST, gRPC, message queues and older agent languages. The workshop slides showed what that looks like.

Image credit: “Why we need another protocol?” slide from the AGNTCon + MCPCon workshop “Hands-on A2A” by Pedro Melendez, Sergio Villani and Sirisha Karra (Google). The same diagram appears in Pedro and Sergio’s Medium article.

As the slide puts it, REST, gRPC and MQTT move bytes between servers, but they don’t standardize how agents discover skills, negotiate tasks or collaborate. A2A fills that gap. Each agent exposes one standard interface over HTTP, and other agents can find it and delegate to it without seeing its prompts, tools or databases.

How A2A works

A2A is an open standard that lets agents built on different frameworks, models or clouds discover each other and work together as peers. The workshop boiled it down to three steps.

Image credit: “How A2A Works” slide from the AGNTCon + MCPCon workshop “Hands-on A2A” by Pedro Melendez, Sergio Villani and Sirisha Karra (Google).

  1. Discover. The client fetches the remote agent’s Agent Card from /.well-known/agent-card.json. The card describes who the agent is, where to reach it, what authentication it needs and what skills it offers.
  2. Delegate. The client sends a goal using a JSON-RPC call such as message/send. The goal can be plain language or structured data. The remote agent reasons about it with its own model.
  3. Stream results. The remote agent does the work privately and streams back status updates and a final artifact.

There are two roles. The A2A client is the orchestrator. It only ever sees the public Agent Card, never the remote agent’s prompts or data. The A2A server is the specialist. It publishes the card, enforces auth, runs the work and reports progress.

Where MCP fits

A common question is, “If I already use MCP, why do I need A2A?” The answer is that they solve different problems and work well together.

  • MCP connects one agent to its own tools: a database, files, an API. A tool call is stateless and predictable. The agent keeps all the planning and control.
  • A2A connects agents to other agents across teams, clouds and frameworks. The agent on the other end can reason, plan, enforce its own security and hold a conversation over several turns.

Pedro offers a simple test. Ask whether your service returns an answer or takes responsibility for an outcome. If it returns an answer, it’s a tool. If it owns the outcome, it’s an agent, and A2A is the better fit.

What the lab builds

The scenario is an analytics request that crosses team lines. The company wants to compare first names in its internal workforce with public US name trends, then save an executive report to a local knowledge base. No single agent is allowed to hold every credential, so four teams each own one agent.

Image credit: “Lab Architecture: What You Will Build” slide from the AGNTCon + MCPCon workshop “Hands-on A2A” by Pedro Melendez, Sergio Villani and Sirisha Karra (Google).

Here is who owns what:

  1. core_analytics_agent (Core Analytics team, Google ADK). It queries the public US Social Security name data in BigQuery and reads and writes saved reports in a local JSON knowledge base through MCP. The workshop slide labels it “My Awesome Analytics Agent.”
  2. partner_openai_agent (a partner or acquired team, OpenAI Agents SDK). It needs the same analytics without copying the core team’s SQL, MCP tools or security code.
  3. gateway_agent (Platform and Security team). It keeps the registry of internal agents and issues short-lived signed tokens, sent as an X-Gateway-Token header.
  4. corporate_names_analytics_agent (HR team). It guards a 5,000-employee corporate directory in SQLite. Any request without a valid gateway token gets a 401.

In the workshop, the gateway and corporate agents ran on Cloud Run in isolated attendee projects, and attendees worked through four tasks: a local agent, REST versus A2A, token gating and cross-framework calls. The slide also shows a workshop leaderboard agent, running on Gemma 4, reached over A2A across the internet.

REST discovery breaks easily

The first lesson compares two ways for the analytics agent to find the HR agent. The REST version calls a lookup endpoint with a hardcoded key:

# Fragile REST approach: hardcoded service_key parameter
def lookup_service_via_rest(service_key: str) -> str:
    """Calls GET /api/v1/lookup?service_key=<service_key>.
    Known service keys: 'corporate_names_analytics_agent'.
    """

This works until the platform team renames the registry entry during an upgrade, to corporate_names_analytics_v2. Then the lookup returns a 400 Bad Request, and the analytics agent can’t reach HR at all. REST only matches exact strings.

A2A discovery and token gating

With A2A, the analytics agent treats the gateway as a remote sub-agent (RemoteA2aAgent) and asks it in plain language for the corporate employee directory and an access token. Three things happen:

  1. Identity. When fetching the gateway’s Agent Card, the analytics agent’s HTTP client attaches its Google Cloud OIDC token in the Authorization header. No API keys pass through prompts.
  2. Resolution and token minting. The gateway’s model maps the request to corporate_names_analytics_v2, checks the caller’s identity, and issues a signed token that expires in 5 minutes and only works for that one service.
  3. The actual work. The analytics agent calls the HR agent with the token, compares names like Alex, Michael and David against historical US birth totals in BigQuery, and saves the report through MCP.

The rename no longer matters, because the caller describes what it needs rather than quoting a key. One caution from the repo: the gateway and HR agent share a demo signing secret in .env.sample so the lab runs out of the box. In production you’d keep that secret in Secret Manager or switch to asymmetric keys with a public JWKS endpoint.

Crossing frameworks

The partner team’s agent is built on the OpenAI Agents SDK. To let it use the analytics workflow, the core team exposes their ADK agent as an A2A server in two lines with to_a2a(root_agent, port=8003). The partner agent keeps its own SDK, uses a Gemini model through the OpenAI-compatible endpoint, and delegates tasks to http://localhost:8003 over A2A.

root_agent = Agent(
    name="partner_openai_agent",
    model=get_gemini_openai_model(os.getenv("MODEL_NAME")),
    instructions=PARTNER_AGENT_INSTRUCTIONS,
    tools=[
        call_core_analytics_a2a_agent,
        contact_discovered_a2a_agent,
    ],
)

Neither team rewrites anything. They agree on the wire protocol, not the SDK.

Tasks that can pause and wait for a person

This is the part I found most useful. An MCP tool call runs once and returns. An A2A task can run for a while, involve several agents, and stop partway to ask a human for approval.

A2A tracks this as a Task object with a taskId and contextId that stay the same across calls such as message/stream, message/send and tasks/get. In the lab, the partner agent asks the analytics agent to look up the name “Ebba” in both the public census data and the HR directory, then save a report. That request moves through five phases:

  1. Discovery and submission. The partner agent reads the analytics agent’s Agent Card and opens a Server-Sent Events stream. The task moves from submitted to working.
  2. First approval gate. Querying HR means getting a privileged token on the user’s behalf, so the analytics agent pauses the task in the input-required state. The partner agent checks it with tasks/get and asks the user: allow core_analytics_agent to get a gateway token and query HR? [Y/n]
  3. Fan-out. After approval, the same task resumes. The analytics agent queries BigQuery, gets a token from the gateway, and calls the HR agent.
  4. Second approval gate. With the data collected, the task pauses again before writing to the local knowledge base. If the user says no, the task stops and nothing is written.
  5. Delivery. After the second approval, the report is saved through MCP, an analytics_report artifact streams back, and the task moves to completed.

The companion repo logs each state change as it happens, so you can watch the task go from submitted to working to input-required and back, and finally to completed. That makes it much easier to see what each agent is doing and where a person stepped in.

What to take away

Here’s my checklist from the workshop and the article:

  1. Keep agents small. Let each team own one focused agent behind an A2A boundary instead of piling every tool and credential into one.
  2. Use MCP and A2A together. MCP connects an agent to its own tools and data. A2A connects agents to each other.
  3. Discover by description, not by key. Agent Cards and plain-language requests survive renames and version changes that break hardcoded REST lookups.
  4. Never share raw credentials. Route access through a gateway that issues short-lived, scoped tokens, check them in middleware, and use the input-required state to pause for human approval before privileged actions.
  5. Standardize the protocol, not the SDK. ADK and OpenAI Agents SDK agents worked together in the lab without either being rewritten.

Where to go next

The workshop closed with a few topics it didn’t cover in full. The A2A spec also defines webhook push notifications, task cancellation, stream reconnection and file and data parts. There’s an a2a-cli tool that lets coding tools like Gemini CLI or Claude Code discover and call A2A agents from the terminal. And in production you’d replace the workshop tokens with OAuth2 or OIDC schemes declared in the Agent Card, plus a managed agent registry.

To try it yourself:

Feel free to post comments with any questions about A2A or the lab. I’m happy to answer them.

Sources and image credits

Leave a Comment