Introduction
The Agent2Agent (A2A) Protocol is an open communication standard that enables AI agents built on different frameworks to communicate and collaborate effectively. While Googleโs official examples rely on cloud services like Google AI Studio and Vertex AI, this guide demonstrates how to run the entire A2A ecosystem using local language models through Ollama and LM Studio, making it accessible to developers worldwide, especially those in regions with limited cloud access.
Today, I'm sharing my journey building a complete Agent-to-Agent (A2A) ecosystem where five different AI frameworks collaborate using local LLMs - no cloud APIs required!
๐ฏ What We're Building
This project demonstrates real cross-agent communication using:
- Travel Agent (Semantic Kernel) - Orchestrates complex trip planning
- Currency Agent (LangGraph) - Provides real-time currency conversion
- YouTube Agent (AG2/AutoGen + MCP) - Extracts video content for research
- Reimbursement Agent (Google ADK) - Handles expense workflows with forms
- File Chat Agent (LlamaIndex) - Enables document conversations with file uploads
All powered by local LLMs (Ollama/LM Studio) and connected via A2A JSON-RPC protocol! ๐ฅ
๐ ๏ธ Core Technologies
Local LLM Infrastructure
- Ollama: Download from ollama.com
- LM Studio: Download from lmstudio.ai
AI Frameworks Integration
Framework | Agent | Purpose | Port |
---|---|---|---|
LangGraph | Currency Agent | Real-time currency conversion | 10000 |
AG2 (AutoGen) | YouTube Agent | Video transcript analysis | 10010 |
Google ADK | Reimbursement Agent | Expense processing with forms | 10020 |
Semantic Kernel | Travel Agent | Trip planning orchestration | 10030 |
LlamaIndex | File Chat Agent | Document parsing & Q&A | 10040 |
๐ป Quick Start Guide
1. Setup Environment
# Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
2. Start Local LLM Service
# Option 1: Ollama
ollama serve
# Option 2: LM Studio
# Download and run LM Studio, load your preferred model
3. Launch Agents
# Currency Agent (LangGraph)
./start_remote_agent.sh langgraph --host localhost --port 10000 --llm-provider ollama --model-name qwen2.5:7b
# YouTube Agent (AG2 + MCP)
./start_remote_agent.sh ag2 --host localhost --port 10010 --llm-provider ollama --model-name qwen2.5:7b
# Travel Agent (Semantic Kernel)
./start_remote_agent.sh semantickernel --host localhost --port 10030 --llm-provider ollama --model-name qwen2.5:7b
# Reimbursement Agent (Google ADK)
./start_remote_agent.sh google_adk --host localhost --port 10020 --llm-provider ollama --model-name qwen2.5:7b
# File Chat Agent (LlamaIndex)
./start_remote_agent.sh llama_index_file_chat --host localhost --port 10040 --llm-provider ollama --model-name qwen2.5:7b
4. Start Host Interface
# Web UI Host
./start_host_agent.sh
# Visit http://localhost:12000
# Or CLI Host
./start_cli.sh --agent http://localhost:10000
๐ง A2A Protocol Implementation
Each agent exposes a standardized Agent Card via .well-known/agent.json
:
{
"name": "Currency Agent",
"description": "Helps with exchange rates for currencies",
"version": "1.0.0",
"url": "http://localhost:10000/",
"capabilities": {
"pushNotifications": true,
"streaming": true
},
"skills": [
{
"id": "convert_currency",
"name": "Currency Exchange Rates Tool",
"description": "Helps with exchange values between various currencies",
"examples": ["What is exchange rate between USD and GBP?"],
"tags": ["currency conversion", "currency exchange"]
}
]
}
Communication happens via JSON-RPC 2.0:
{
"jsonrpc": "2.0",
"id": 1,
"method": "message/send",
"params": {
"sessionId": "test-session",
"message": {
"messageId": "msg-01",
"role": "user",
"parts": [{
"type": "text",
"text": "Convert 100 USD to CNY"
}]
}
}
}
๐ฎ Real-World Demo: Multi-Agent Travel Planning
Here's where the magic happens! Let's see how agents collaborate:
# User request to Travel Agent
curl -X POST http://localhost:10030 \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "message/send",
"params": {
"message": {
"role": "user",
"parts": [{
"text": "Plan a 7-day Seoul trip with $5000 budget, include currency conversion"
}]
}
}
}'
What happens behind the scenes:
- Travel Agent receives the request
- Automatically calls Currency Agent to get USDโKRW exchange rate
- Plans detailed itinerary with converted budget
- Returns comprehensive travel plan with real currency data
Response:
# ๐ Seoul 7-Day Travel Plan
## ๐ฐ Budget & Exchange Rate
- **Total Budget**: 5000 USD
- **Current Rate**: 1 USD = 1376.78 KRW
- **Korean Won Budget**: ~6,883,900 KRW
## ๐๏ธ Detailed Itinerary
### Day 1: Arrival Seoul (Budget: 800,000 KRW)
- **Accommodation**: Myeongdong Hotel (120,000 KRW/night)
- **Transport**: Incheon Airport Express โ Myeongdong (9,000 KRW)
- **Dinner**: Myeongdong street food (30,000 KRW)
...
๐ฅ Advanced Features
1. Multi-Framework Integration
Each agent uses its native framework:
- LangGraph: Graph-based workflow for currency conversion
- Semantic Kernel: Plugin architecture for travel planning
- AG2 + MCP: Multi-agent collaboration with Model Context Protocol
- Google ADK: Form-based workflows for reimbursements
- LlamaIndex: RAG pipeline for document chat
2. Form-Based Interactions
The Reimbursement Agent demonstrates complex form workflows:
{
"status": {
"state": "input-required",
"message": {
"parts": [{
"data": {
"form": {
"type": "object",
"properties": {
"date": {"type": "string", "format": "date"},
"amount": {"type": "string", "format": "number"},
"purpose": {"type": "string"}
}
},
"form_data": {
"amount": "500",
"purpose": "Business trip transportation"
}
}
}]
}
}
}
3. File Upload & Processing
File Chat Agent handles multiple formats:
{
"parts": [
{
"type": "text",
"text": "Analyze this document"
},
{
"type": "file",
"file": {
"name": "report.pdf",
"mimeType": "application/pdf",
"bytes": "base64-encoded-content"
}
}
]
}
๐ฏ Key Benefits
๐ Privacy First
- 100% Local: No data sent to cloud APIs
- Your LLMs: Use any model you prefer
- Full Control: Complete ownership of your AI pipeline
๐งฉ Framework Flexibility
- Best of Both Worlds: Use each framework's strengths
- Easy Integration: Standardized A2A protocol
- Modular Design: Add/remove agents independently
๐ Production Ready
- Streaming Support: Real-time responses
- Error Handling: Robust error recovery
- Monitoring: Built-in logging and debugging
๐ Resources & Links
๐ Conclusion
Building a multi-agent AI ecosystem doesn't have to be complex. With the right architecture and standardized protocols, different AI frameworks can collaborate seamlessly.
The future of AI is collaborative - where specialized agents work together to solve complex problems. This project shows it's not just possible, but practical with today's tools!
Enjoy ๐
Top comments (0)