Content
# Agent-to-Agent (A2A) Protocol Demonstration
This project demonstrates a simplified version of Google's Agent-to-Agent (A2A) protocol for AI agent communication. It showcases how multiple specialized agents can work together through standardized API endpoints.
## Project Overview
This demo implements three distinct provider agents with different capabilities:
Summarizer Agent: Shortens input text
Text Generator Agent: Generates additional text based on prompt
Sentiment Analyzer Agent: Evaluates text sentiment
A requester agent then delegates tasks to the appropriate provider based on capabilities.
Project Structure
```a2a-multi-capability-demo/
├── agentdirectory.json
├── agentprovider.py
├── agentrequester.py
├── runsummarize.py
├── rungenerate.py
├── runanalyze.py
└── requirements.txt
```
Installation
Clone this repository:
```
git clone https://github.com/albingcj/a2a-protocol-demo.git
cd a2a-protocol-demo
```
Create and activate a virtual environment (optional but recommended):
```
python -m venv env
On Windows
.\env\Scripts\activate
On macOS/Linux
source env/bin/activate
```
Install dependencies:
```
pip install -r requirements.txt
python -m textblob.download_corpora
```
## Running the Demo
Start each agent in a separate terminal window:
Terminal 1 - Summarizer Agent
```
python run_summarize.py
```
Terminal 2 - Text Generator Agent
```
python run_generate.py
```
Terminal 3 - Sentiment Analyzer Agent
```
python run_analyze.py
```
In a fourth terminal, run the requester agent:
```
python agent_requester.py
```
## How It Works
The agent_directory.json defines the available agents and their capabilities
Each agent runs as a separate FastAPI service on different ports
The requester agent:
Reads the agent directory to discover available agents
Matches tasks to agent capabilities
Sends requests to the appropriate agent endpoints
Processes and displays responses
Expected Output
```
Provider: SummarizationAgent
Task ID: 44d10dca-4a74-4f2a-a104-b3d1c2e9f5c7
Task Status: completed
Result: Google's Agent2Agent protocol enables AI agents to collaborate effectively and share tasks secu...
Provider: TextGeneratorAgent
Task ID: dbbf4ce8-29c8-4f4b-b8a7-51c6359204bb
Task Status: completed
Result: The future of AI agents [This is AI-generated continuation.]
Provider: SentimentAnalysisAgent
Task ID: a3d1bf01-dcc7-4045-b4b3-930df846f7ee
Task Status: completed
Result: {'sentiment': 'Positive', 'polarity': 0.625, 'subjectivity': 0.8}
```
## Note on Implementation
This is a simplified demonstration focusing on the communication protocol rather than sophisticated AI capabilities. In a production environment, each agent would typically be powered by advanced language models rather than the simple functions used here.
## Key Concepts Demonstrated
Agent Discovery: Dynamic task routing based on capabilities
Standardized Communication: Consistent JSON-based API structure
Multi-Agent Collaboration: Coordinating different specialized services
Task Delegation: Matching tasks to the appropriate service provider
Future Enhancements
Integrate actual LLMs for more sophisticated agent capabilities
Add authentication and security measures
Implement asynchronous processing for long-running tasks
Add context sharing between agents for more coherent multi-step workflows