Exploring Google’s A2A AI System: Agent-to-Agent Workflows, Routing, and Conversation History
This project demonstrates an Agent-to-Agent (A2A) system, where autonomous AI agents communicate, collaborate, and complete complex workflows with minimal human intervention. The system leverages multiple agents, a self-hosted MCP server, and third-party services like Exa MCP from Smithery.ai to handle specialized tasks such as code generation, media retrieval, audio/document processing, and web searches.
- Agents are represented as Agent Cards in the React client, containing metadata such as skills, input/output modes, tags, and state history.
- Agents can be dynamically added or removed at runtime without restarting the system.
- This approach supports a loosely coupled, scalable architecture, enabling multiple agents to be discovered, registered, and routed automatically.
- The Routing Service intelligently dispatches prompts to the most appropriate agent based on skills, tags, and availability.
- If no specialized agent can handle a request, the AI Assistant takes over as a fallback, preserving the last five conversations in memory.
- Server-side routing keeps sensitive API keys secure and avoids exposing logic to the client.
- This allows the system to handle dynamic and changing workflows without manual intervention.
- Agents operate via tasks (discrete units of work) and events (updates, results, or status changes).
- Streaming agents send incremental updates, giving clients real-time feedback as tasks progress.
- Non-streaming agents return final results once the task completes.
TaskArtifactUpdateEventensures that all generated outputs, such as code files or media, are broadcasted to clients and other agents, keeping the system synchronized.- Event-based architecture allows asynchronous collaboration, so multiple agents can work independently while staying aligned.
- The Model Context Protocol (MCP) server provides a language-agnostic interface for tools and external data, making them reusable across different projects and environments.
- Agents can access multiple tools without duplicating code, ensuring consistency and reducing integration errors.
- Tools are exposed via SSE transport, enabling modular and multi-task workflows.
- This setup is particularly useful when multiple agents need access to the same tool or service across languages (Python, JavaScript, Java, etc.).
- Integrates external tools like Exa MCP from Smithery.ai using
StdioClientTransportfor real-time web searches. - Agents execute CLI commands, perform searches, and return structured JSON results, which can be parsed and displayed in a human-readable format.
- External integrations expand agent capabilities without modifying internal architecture, supporting seamless cross-project interoperability.
- Example use cases include fetching relevant programming documentation, retrieving YouTube content, generating images, and providing real-time insights from the web.
- Each session is tracked using a
contextId, maintaining per-agent conversation history. - Context enables agents to generate coherent, context-aware responses across multiple prompts.
- When a new conversation is initiated, memory resets, allowing fresh interactions without residual context.
- This mechanism also ensures that agents do not interfere with each other's histories, keeping workflows modular and organized.
- Streaming agents: Provide incremental status updates to clients, showing progress and partial results in real time. Examples include code generation or audio processing.
- Non-streaming agents: Only provide final outputs once the task completes. Important task events are still broadcast but not incrementally displayed. Examples include image generation or certain search queries.
- This distinction allows the system to balance performance and responsiveness depending on the agent’s task and external tooling.
- Fully supported in VS Code via AI-generated launch configurations.
- Developers can run individual agents or the entire system (agents + client).
- Real-time monitoring of tasks and event streams simplifies debugging complex multi-agent interactions.
- Supports both streaming and non-streaming modes for flexible testing.
- The system allows restarting only the agent of interest without disrupting others, enabling efficient iterative development.
This A2A project demonstrates a scalable, modular, and dynamic framework for AI collaboration.
- Agents can handle specialized, multi-step tasks, sharing results and updates across the system.
- Flexible integration of self-hosted MCP tools and third-party services like Exa MCP enables robust multi-agent workflows.
- Context-aware memory and streaming support provide responsive, real-time interactions.
- Developers can extend the system easily, adding new agents or tools without major refactoring.
The framework showcases how autonomous AI agents can work together efficiently, minimizing human intervention while maintaining control and observability.
# Clone the repository
git clone https://github.com/Ashot72/multi-agent-a2a
# Server
cd multi-agent-a2a/server
# Copy env-template.txt to .env in the root directory and fill in your actual API keys.
# Install dependencies
npm install --legacy-peer-deps
# Starts the server
npm run agents:all
# Client
cd multi-agent-a2a/client
# Install dependencies
npm install
# Starts the Vite app at http://localhost:5173
npm run dev
The project is fully supported in VS Code via AI-generated launch configurations:
- Open the Run view (
View → RunorCtrl+Shift+D) to access all debug configurations. - Run individual agents or the entire system (agents + client) as needed.
This setup streamlines development and allows quick iteration on agent behavior and workflows.
📺 Video: Watch on YouTube
