Sitemap

Introducing Agent2Agent (A2A): Understanding Google’s Protocol for AI Collaboration

11 min readApr 21, 2025

--

In the rapidly evolving landscape of AI, intelligent agents, autonomous systems that act on behalf of users, are becoming increasingly capable. However, despite their individual advancements, most agents today function in silos. Recognizing the need for seamless collaboration among AI agents, Google has introduced the Agent2Agent (A2A) Protocol, an open framework designed to enable secure, interoperable communication between different AI agents.

What is A2A?

A2A (Agent2Agent) is an open protocol and communication standard that allows AI agents, regardless of who developed them or what platform they operate on, to talk to one another. Inspired by the open nature of the web, A2A envisions a future where agents can dynamically collaborate to fulfill user goals across services, devices, and ecosystems.

Whether it’s a travel planning agent coordinating with a calendar assistant, or a shopping bot checking availability across multiple stores, A2A enables them to securely exchange structured messages, coordinate actions, and share intent all without tight platform coupling or proprietary constraints.

Key Features of the A2A Protocol

1. Decentralized and Open
A2A is designed to be platform-agnostic, allowing any agent to participate regardless of vendor or environment. This decentralization avoids the vendor lock-in that currently limits AI agent collaboration.

2. Security and Trust
Communication between agents is protected using OAuth 2.0, digital signatures, and robust authentication mechanisms, ensuring that users’ data and intent are handled securely and respectfully.

3. Structured Message Format
Agents communicate through structured JSON-based messages that encapsulate actions, intents, results, and metadata making interaction predictable and easy to process across different systems.

4. Agent Directory
A2A provides a directory system that helps agents discover and identify other trusted agents on the network, much like DNS does for websites.

5. Event and Intent Handling
Agents can trigger and respond to events, fulfill intents, and pass along actions with responses, enabling dynamic workflows between multiple AI agents.

Why A2A Matters

The rise of intelligent agents like voice assistants, personal bots, and task-specific AI tools has increased demand for coordination. However, until now, collaboration was largely restricted to within an ecosystem (e.g., Google Assistant working only with Google services). A2A seeks to break down these barriers, allowing an agent from one provider to seamlessly collaborate with another.

This opens the door to a future where agents:

  • Plan, book, and confirm a full itinerary across different platforms.
  • Collaborate to manage home devices from different ecosystems.
  • Automate workflows involve third-party services and APIs.

Core Components of the A2A Protocol

1. Agent Card

At the heart of the A2A Protocol is the concept of the Agent Card. This is akin to a digital business card for AI agents, providing essential metadata that includes:

  • Agent Identity: Unique identifiers and authentication credentials.
  • Capabilities: A list of tasks or services the agent can perform.
  • Communication Endpoints: URLs or interfaces through which the agent can be contacted.
  • Supported Interaction Modalities: Information on whether the agent supports text, audio, video, or other forms of communication.

Agents expose their AgentCards at a standardized endpoint (typically /.well-known/agent.json), allowing other agents to discover and assess their capabilities before initiating interactions.

2. Tasks

Tasks are the fundamental units of work exchanged between agents in the A2A ecosystem. Each task comprises:

  • Task Identifier: A unique ID for tracking purposes.
  • Payload: The actual content or instructions of the task.
  • Status Information: Indicators such as ‘pending’, ‘in progress’, or ‘completed’.
  • Metadata: Additional information to aid in task execution and coordination.

By standardizing task structures, A2A ensures that agents can effectively interpret and act upon tasks received from other agents, facilitating smooth collaboration.

How A2A Works

Step-by-Step Breakdown:

  1. Fetch Agent Card
    The Client Agent starts by fetching the Agent Card from the A2A Server. This card contains metadata about the server agent’s identity, capabilities, and endpoints.
  2. Receive Agent Card
    The A2A Server responds with its Agent Card. This helps the Client Agent understand what the server agent can do and how to communicate with it.
  3. Generate Task ID
    The Client Agent then prepares a request and generates a unique Task ID for tracking the task across systems.
  4. Send Task
    The Client Agent sends the task to the A2A Server. This includes the generated Task ID and the actual request payload (i.e., the instructions or intent).
  5. Process Task
    The A2A Server receives the task and begins processing it based on the instructions.
  6. Respond with Task ID
    Once the processing is complete (or acknowledged), the A2A Server sends a response back to the Client Agent using the Task ID. This allows the client to associate the result with the original request.

Security and Authentication

Security is a paramount concern in agent-to-agent communications. The A2A Protocol incorporates robust security measures, including:

  • OAuth 2.0: For secure authorization and access delegation.
  • Digital Signatures: To verify the authenticity and integrity of messages.
  • Role-Based Access Control (RBAC): Ensuring agents have appropriate permissions for the tasks they undertake.
  • End-to-End Encryption: Protecting data integrity and confidentiality throughout the communication process.

Integration with Model Control Protocol (MCP)

While A2A focuses on facilitating communication between agents, it can be synergistically combined with the Model Control Protocol (MCP). MCP provides a standardized interface for agents to access external tools, data sources, and services. Together, A2A and MCP enable:

  • Comprehensive Workflows: Agents can not only communicate but also leverage external resources to complete complex tasks.
  • Enhanced Collaboration: Agents can delegate subtasks to specialized agents or services, optimizing efficiency.
  • Scalable Architectures: Systems can be designed with modular agents that interact seamlessly, promoting scalability and maintainability.

Real-World Applications

The A2A Protocol has broad applicability across various domains:

  • Customer Support: Different AI agents handling billing, technical support, and account management can collaborate to resolve customer issues more efficiently.
  • Healthcare: Agents managing patient records, appointment scheduling, and diagnostics can coordinate to provide comprehensive care.
  • Smart Homes: Devices from different manufacturers can interact, enabling cohesive automation scenarios.
  • Enterprise Workflows: AI agents across departments can synchronize tasks, improving operational efficiency.

Real-World Example: AI Agent Collaboration Using A2A

What’s Going on Under the Hood?

  1. A2A Communication Begins
    The Client starts by sending a task using the Agent-to-Agent (A2A) Protocol to the Gateway Agent Server, this server acts like the smart controller or traffic router of your system.
  2. Gateway Decides
    Based on the user’s query, the Gateway Agent decides what to do next:
  • It might send the task directly to ChatGPT-4o via HTTPS (if it can answer it solo).
  • Or it may forward the task using A2A to a specialized agent:
  • Search Agent → Uses tools like Brave Search via MCP and ChatGPT to pull in fresh web results.
  • RAG Agent → Connects to a Local RAG system through MCP for custom or private knowledge retrieval.

3. How Everything Connects
The entire system smartly mixes three communication layers:

  • A2A (Agent-to-Agent) → For structured internal agent communication
  • HTTPS → For making public API calls (e.g., OpenAI, Brave, etc.)
  • MCP (Model Communication Protocol) → For deep integration with tools like local RAG servers or custom search systems.

Code Breakdown

1.client.py: A Command-Line Client for Talking to the Agent

1.1 Agent Discovery with Agent Card(client.py)

Before talking to an agent, the client needs to know if it’s available, and what it can do.

What It Does: Fetches metadata about the agent (like its name, version, and capabilities).

1.2 Taking User Input in a Loop(client.py)

It turns this script into a simple chatbot experience in your terminal.

What It Does: Waits for the user to type a question. It keeps running until the user types quit.

1.3 Sending User Questions to the Agent(client.py)

This is where the client “talks” to the agent, submitting a support ticket and waiting for a reply.

What It Does: Sends your input to the agent’s /tasks/send endpoint.

1.4 Receiving and Displaying the Agent’s Reply(client.py)

Ensure you see a clean, readable answer, even if it’s broken into parts.

What It Does:
Extracts and prints the agent’s response from the message structure.

2. brave_search_server.py: Building a Web-Connected AI Agent with Brave Search

2.1 MCP Server for Brave Search(brave_search_server.py)

This is the core engine that allows your agent to perform live internet searches through Brave.

What It Does: Launches a Brave Search MCP server using npx and passes your Brave API key from the .env file.

2.2 Agent Setup with Web Access(brave_search_server.py)

The system prompt tells the model it can use web search this helps guide how the LLM interprets your request.

What It Does: Creates an agent that uses OpenAI’s model but now with a search-enabled system prompt and linked Brave MCP server.

2.3 Serving Agent Metadata(brave_search_server.py)

This allows agent-to-agent communication (A2A) or discovery tools to understand what this agent does.

What It Does: Provides a public JSON card with the agent’s name, description, and capabilities.

2.4 Handling User Task Requests(brave_search_server.py)

This is the key communication channel between the user (or another system) and the agent.

What It Does: Listens for incoming user questions, passes them to the agent, and returns the web-informed result.

2.5 Running the Brave-Powered Agent(brave_search_server.py)

Without this line, your agent won’t be able to search the web! This kicks off the real-time Brave search process.

What It Does: Starts the Brave MCP server in the background, runs the agent with the user’s input, and gets the answer.

2.6 Crafting the Response Back to the User(brave_search_server.py)

Follows the standard message format used across agents in A2A communication.

What It Does: Wraps the response in the A2A-compatible format and sends it back.

3. gateway_server.py: The Smart AI Router for our Agents

3.1 OpenAI Key Setup and Fallback(gateway_server.py)

The routing logic is powered by OpenAI. Without the key, it skips smart routing and sends everything to the Search Agent.

What It Does: Loads your OpenAI API key from the .env file. If it’s missing, the gateway defaults to using the Search Agent.

3.2 Agent URLs for Routing(gateway_server.py)

What It Does: Defines where your Search and RAG agents live these are the two destination choices the router can send queries to.

3.3 The Brain: Routing with OpenAI(gateway_server.py)

This is the decision-maker, our gateway is not just blindly forwarding queries, it thinks about where to send them.

What It Does: Uses an OpenAI model (gpt-3.5-turbo) to decide whether a query is better suited for the RAG Agent or the Search Agent.

Prompt Example Given to OpenAI:

“You are an intelligent request router. Choose between RAG (local) or Search (web)…”

Returns: “RAG” or “SEARCH” and maps that to the right agent’s URL.

3.4 Handling User Requests(gateway_server.py)

What It Does: Accepts incoming A2A-style tasks, extracts the user’s query, and then:

  1. Routes it is using route_query_with_openai
  2. Forwards the query to the chosen agent’s /tasks/send endpoint

Returns that agent’s response to the original requester

3.5 Serving Gateway Metadata(gateway_server.py)

What It Does: Provides an Agent Card describing this gateway’s identity and functionality.

4. rag_agent_server.py: The Local RAG-Powered Question Answering Agent

4.1 Connect to Local RAG Server via MCP (rag_agent_server.py)

This is what makes your assistant “smart locally” it pulls info from your custom knowledge base.

What It Does: Launches your local RAG server using uv and runs the server.py inside your Local-MCP folder.

4.2 Create the Agent with OpenAI + RAG(rag_agent_server.py)

This hybrid setup gives you GPT’s reasoning + your own data via the RAG backend. Best of both worlds!

What It Does:

  • Configures the agent to use OpenAI’s GPT-4o-mini.
  • Adds a custom system prompt that instructs it to use knowledge from the local RAG server.

4.3 Agent Identity: Serving the Agent Card(rag_agent_server.py)

In multi-agent setups (like A2A), agents discover each other using this card.

What It Does:

  • Provides metadata about this RAG agent (name, URL, capabilities).
  • Serves it at .well-known/agent.json.

4.4 The Brain: Handling Incoming Tasks(rag_agent_server.py)

What It Does:

  • Accepts task requests in A2A format (usually from the Gateway).
  • Extracts the user’s message.
  • Runs the agent using local RAG + OpenAI.
  • Responds with the answer or an error.

Let’s break down the internals:

4.4.1 Get Task + User Query(rag_agent_server.py)

Extracts the user’s query from the request.

4.4.2 Process the Query with the RAG Agent(rag_agent_server.py)

Use the RAG-powered agent to get an answer.

4.4.3 Return a Completed A2A Task(rag_agent_server.py)

Wraps the agent’s answer in the A2A task response format.

4.5 Launch the Agent Server(rag_agent_server.py)

This makes the RAG agent live and ready to receive user questions via the gateway or orchestrator.

What It Does: Starts the Flask server on localhost:5006.

Agent-to-Agent (A2A) Architecture Code Components

You can explore this open-source implementation and try it on your own.

Agent2Agent (A2A) is a bold step toward a more interoperable and collaborative AI ecosystem. By enabling secure and open communication between agents, Google is laying the groundwork for a future where AI works not just for us but with each other. As the agent ecosystem grows, A2A could become the glue that makes our digital assistants truly intelligent and interconnected.

--

--

Priyal Walpita
Priyal Walpita

Written by Priyal Walpita

CTO & Co-Founder @ Zafer AI | Seasoned Software Architect | Expertise in AI/ML , Blockchain , Distributed Systems and IoT | Lecturer | Speaker | Blogger

Responses (1)