This project provides complete A2A (Agent-to-Agent) protocol implementations in five programming languages: Java, Python, JavaScript/TypeScript, C#, and Go. Each implementation includes both agent (server) and host (client) components with support for three transport protocols.
The Aloha A2A framework demonstrates cross-language interoperability using the A2A protocol specification. Each language implementation supports:
- Three Transport Protocols: JSON-RPC 2.0, gRPC, and HTTP+JSON/REST
- Streaming Communication: Real-time bidirectional data flow
- Agent and Host: Complete server and client implementations
- Example Tools: Dice rolling and prime number checking
- Cross-Language Compatibility: Any host can communicate with any agent regardless of language
The Agent-to-Agent (A2A) protocol is a standardized communication protocol that enables AI agents to interact with each other seamlessly. It provides:
- Standardized Message Format: Consistent structure for agent communication
- Multiple Transport Options: Flexibility to choose the best transport for your use case
- Streaming Support: Real-time updates during long-running operations
- Task Management: Track and manage asynchronous operations
- Agent Discovery: Discover agent capabilities through agent cards
| Language | Agent | Host | SDK Version |
|---|---|---|---|
| Java | ✓ | ✓ | v0.3.0.Beta2 |
| Python | ✓ | ✓ | v0.3.10 |
| JavaScript/TypeScript | ✓ | ✓ | v0.3.4 |
| C# | ✓ | ✓ | v0.3.3-preview |
| Go | ✓ | ✓ | latest |
aloha-a2a/
├── aloha-java/ # Java implementation
├── aloha-python/ # Python implementation
├── aloha-js/ # JavaScript/TypeScript implementation
├── aloha-csharp/ # C# implementation
├── aloha-go/ # Go implementation
├── test-suite/ # Cross-language interoperability test suite
└── README.md # This file
Before getting started, ensure you have the following installed:
- Ollama: Local LLM runtime (required for all implementations)
- Java: JDK 21+ and Maven 3.8+ (for Java implementation)
- Python: Python 3.11+ and pip or uv (for Python implementation)
- Node.js: Node.js 18+ and npm (for JavaScript implementation)
- .NET: .NET 8.0+ SDK (for C# implementation)
- Go: Go 1.21+ (for Go implementation)
Ollama is required to run the LLM-powered agents. Install it for your platform:
macOS:
brew install ollamaLinux:
curl -fsSL https://ollama.ai/install.sh | shWindows: Download from https://ollama.ai/download
Pull the qwen2.5 model:
ollama pull qwen2.5Start Ollama service (if not auto-started):
ollama serveVerify installation:
ollama listHere's a quick example using Python:
Step 1 - Ensure Ollama is running:
# Check if Ollama is running
ollama list
# If not running, start it
ollama serveStep 2 - Start the Agent:
cd aloha-a2a/aloha-python/agent
pip install -e .
python -m agentStep 3 - Run the Host:
cd aloha-a2a/aloha-python/host
pip install -e .
python -m host --message "Roll a 6-sided dice"You should see the agent process your request using Ollama's qwen2.5 model and return a dice roll result!
Each language directory contains its own README with specific setup instructions. General steps:
- Navigate to the language directory (e.g.,
cd aloha-java) - Follow the setup instructions in the language-specific README
- Start the agent server
- Run the host client to interact with the agent
See the Language-Specific Setup section below for detailed instructions.
The A2A protocol supports three transport mechanisms, each with different characteristics:
Each language implementation uses a dedicated port range to avoid conflicts:
| Language | gRPC Port | JSON-RPC Port | REST Port |
|---|---|---|---|
| Java | 11000 | 11001 | 11002 |
| Go | 12000 | 12001 | 12002 |
| Python | 13000 | 13001 | 13002 |
| JavaScript | 14000 | 14001 | 14002 |
| C# | 15000 | 15001 | 15002 |
See PORT_CONFIGURATION.md for detailed port configuration information.
- Protocol: Binary protocol with HTTP/2
- Best for: High-performance, low-latency communication
- Streaming: Bidirectional streaming support
- Use case: Microservices, high-throughput scenarios
Example connection:
# Java agent
grpc://localhost:11000
# Python agent
grpc://localhost:13000- Protocol: WebSocket or HTTP POST
- Best for: Real-time bidirectional communication
- Streaming: Native WebSocket streaming
- Use case: Interactive applications requiring low latency
Example connection:
# WebSocket to Java agent
ws://localhost:11001
# HTTP POST to Python agent
curl -X POST http://localhost:13001/jsonrpc \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"message/send","params":{...},"id":1}'- Protocol: Standard HTTP with JSON payloads
- Best for: Simple integration, debugging, web applications
- Streaming: Server-sent events (SSE)
- Use case: Web applications, easy debugging, broad compatibility
Example connection:
# Send message to Java agent
curl -X POST http://localhost:11002/v1/message:send \
-H "Content-Type: application/json" \
-d '{
"kind": "message",
"messageId": "msg-123",
"role": "user",
"parts": [{"kind": "text", "text": "Roll a 6-sided dice"}],
"contextId": "ctx-123"
}'
# Get agent card from Python agent
curl http://localhost:13002/.well-known/agent-card.json| Feature | JSON-RPC 2.0 | gRPC | REST |
|---|---|---|---|
| Ease of Use | Medium | Medium | Easy |
| Performance | Good | Excellent | Good |
| Debugging | Medium | Hard | Easy |
| Browser Support | Yes (WebSocket) | Limited | Yes |
| Streaming | Native | Native | SSE |
| Binary Data | No | Yes | No |
Recommendation: Start with REST for development and debugging, then switch to gRPC for production if performance is critical.
All implementations are designed to be fully interoperable. You can:
- Run a Java agent and connect with a Python host
- Run a Python agent and connect with a C# host
- Mix and match any language combination across any transport protocol
The framework supports 75 combinations (5 languages × 5 languages × 3 transports):
Host Language → Agent Language
↓
Java, Python, JavaScript, C#, Go
×
Java, Python, JavaScript, C#, Go
×
JSON-RPC 2.0, gRPC, REST
All combinations are tested and validated. See the Testing section for details.
Scenario: Python host communicating with Java agent via gRPC
Terminal 1 - Start Java Agent:
cd aloha-a2a/aloha-java/agent
mvn compile quarkus:devTerminal 2 - Run Python Host:
cd aloha-a2a/aloha-python/host
python -m host --transport grpc --port 13000 --message "Roll a 20-sided dice"The Python host successfully communicates with the Java agent, demonstrating true cross-language interoperability!
Requirements: JDK 21+, Maven 3.8+, Ollama (for LLM)
Setup Agent:
cd aloha-a2a/aloha-java/agent
mvn clean install
mvn compile quarkus:devRun Host:
cd aloha-a2a/aloha-java/host
mvn compile exec:java -Dexec.args="--transport grpc --port 11000 --message 'Roll a 6-sided dice'"Documentation: aloha-java/README.md
Requirements: Python 3.11+, pip or uv
Setup Agent:
cd aloha-a2a/aloha-python/agent
pip install -e .
python -m agentRun Host:
cd aloha-a2a/aloha-python/host
pip install -e .
python -m host --transport rest --port 13002 --message "Roll a 20-sided dice"Documentation: aloha-python/README.md
Requirements: Node.js 18+, npm
Setup Agent:
cd aloha-a2a/aloha-js/agent
npm install
npm run build
npm startRun Host:
cd aloha-a2a/aloha-js/host
npm install
npm run build
npm start -- --transport rest --port 14002 --message "Is 17 prime?"Documentation: aloha-js/README.md
Requirements: .NET 8.0+ SDK
Setup Agent:
cd aloha-a2a/aloha-csharp/Agent
dotnet restore
dotnet runRun Host:
cd aloha-a2a/aloha-csharp/Host
dotnet run -- --transport rest --port 15002 --message "Check if 2, 7, 11 are prime"Documentation: aloha-csharp/README.md
Requirements: Go 1.21+
Setup Agent:
cd aloha-a2a/aloha-go/agent
go build
./agentRun Host:
cd aloha-a2a/aloha-go/host
go build
./host --transport grpc --port 12000 --message "Roll a 12-sided dice and check if it's prime"Documentation: aloha-go/README.md
Each agent implementation provides two example tools:
Rolls an N-sided dice and returns a random number between 1 and N.
Examples:
- "Roll a 6-sided dice"
- "Roll a 20-sided dice"
- "Roll a d12"
Tool Signature:
roll_dice(sides: int) -> int
Checks which numbers in a list are prime numbers.
Examples:
- "Is 17 prime?"
- "Check if 2, 4, 7, 9, 11 are prime"
- "Are these numbers prime: 13, 15, 19"
Tool Signature:
check_prime(numbers: list[int]) -> string
- Agent Card: Metadata describing agent capabilities served at
/.well-known/agent-card.json - Streaming: Real-time status updates during processing
- Task Management: Track task status and cancel ongoing operations
- Session Management: Maintain conversation context across multiple messages
- Error Handling: Graceful error handling with descriptive messages
- LLM Integration: Natural language understanding powered by Ollama qwen2.5 model
- Multi-Language Support: qwen2.5 provides excellent Chinese and English language support
{
"name": "Dice Agent",
"description": "An agent that can roll arbitrary dice and check prime numbers",
"url": "localhost:11002",
"version": "1.0.0",
"capabilities": {
"streaming": true,
"pushNotifications": false
},
"skills": [
{
"id": "roll-dice",
"name": "Roll Dice",
"description": "Rolls an N-sided dice",
"examples": ["Roll a 20-sided dice"]
},
{
"id": "check-prime",
"name": "Prime Checker",
"description": "Checks if numbers are prime",
"examples": ["Is 17 prime?"]
}
]
}When running a host, you can specify which transport protocol to use:
Python (connect to Python agent):
python -m host --transport jsonrpc --port 13001 --message "Roll a dice"Java (connect to Java agent):
mvn exec:java -Dexec.args="--transport jsonrpc --port 11001 --message 'Roll a dice'"JavaScript (connect to JS agent):
npm start -- --transport jsonrpc --port 14001 --message "Roll a dice"C# (connect to C# agent):
dotnet run -- --transport jsonrpc --port 15001 --message "Roll a dice"Go (connect to Go agent):
./host --transport jsonrpc --port 12001 --message "Roll a dice"Python (connect to Python agent):
python -m host --transport grpc --port 13000 --message "Roll a dice"Java (connect to Java agent):
mvn exec:java -Dexec.args="--transport grpc --port 11000 --message 'Roll a dice'"JavaScript (connect to JS agent):
npm start -- --transport grpc --port 14000 --message "Roll a dice"C# (connect to C# agent):
dotnet run -- --transport grpc --port 15000 --message "Roll a dice"Go (connect to Go agent):
./host --transport grpc --port 12000 --message "Roll a dice"Python (connect to Python agent):
python -m host --transport rest --port 13002 --message "Roll a dice"Java (connect to Java agent):
mvn exec:java -Dexec.args="--transport rest --port 11002 --message 'Roll a dice'"JavaScript (connect to JS agent):
npm start -- --transport rest --port 14002 --message "Roll a dice"C# (connect to C# agent):
dotnet run -- --transport rest --port 15002 --message "Roll a dice"Go (connect to Go agent):
./host --transport rest --port 12002 --message "Roll a dice"- Ollama: Local LLM runtime with qwen2.5 model
- Installation: See Installing Ollama section above
- Model:
ollama pull qwen2.5 - Service:
ollama serve(must be running)
See individual language READMEs for specific requirements:
- Java: JDK 21+, Maven 3.8+, Ollama
- Python: Python 3.11+, uv or pip, Ollama
- JavaScript: Node.js 18+, npm or pnpm, Ollama
- C#: .NET 8.0+, Ollama
- Go: Go 1.21+, Ollama
Symptom: Agent fails to start or exits immediately
Solutions:
- Check if ports are already in use:
# Check Java agent ports lsof -i :11000 lsof -i :11001 lsof -i :11002 # Check Python agent ports lsof -i :13000 lsof -i :13001 lsof -i :13002
- Kill processes using the ports:
kill -9 $(lsof -ti:11000)
- Check dependencies are installed
- Review agent logs for error messages
Symptom: Connection timeout or refused
Solutions:
- Verify agent is running:
# Java agent curl http://localhost:11002/.well-known/agent-card.json # Python agent curl http://localhost:13002/.well-known/agent-card.json
- Check transport and port match (see PORT_CONFIGURATION.md):
- Java: gRPC 11000, JSON-RPC 11001, REST 11002
- Go: gRPC 12000, JSON-RPC 12001, REST 12002
- Python: gRPC 13000, JSON-RPC 13001, REST 13002
- JavaScript: gRPC 14000, JSON-RPC 14001, REST 14002
- C#: gRPC 15000, JSON-RPC 15001, REST 15002
- Verify firewall settings
- Check agent logs for errors
Symptom: Agent starts but can't process requests, or "Ollama connection failed" errors
Solutions:
-
Check Ollama is running:
# Check if Ollama is running curl http://localhost:11434/api/tags # If not running, start it ollama serve
-
Verify qwen2.5 model is installed:
# List installed models ollama list # If qwen2.5 is not listed, pull it ollama pull qwen2.5
-
Check Ollama connection settings:
# Default Ollama URL (should work for local setup) export OLLAMA_BASE_URL=http://localhost:11434 export OLLAMA_MODEL=qwen2.5
-
Test Ollama directly:
# Test if Ollama responds curl http://localhost:11434/api/generate -d '{ "model": "qwen2.5", "prompt": "Hello" }'
-
Check agent logs for specific Ollama error messages
-
Restart Ollama service:
# Stop Ollama pkill ollama # Start Ollama ollama serve
Java:
cd aloha-java
mvn clean install -UPython:
cd aloha-python/agent
pip install --upgrade pip
pip install -e . --force-reinstallJavaScript:
cd aloha-js/agent
rm -rf node_modules package-lock.json
npm installC#:
cd aloha-csharp
dotnet clean
dotnet restore
dotnet buildGo:
cd aloha-go
go clean -modcache
go mod tidy
go build ./...- Check language-specific README files
- Review agent logs
- Test agent card endpoint
- Verify A2A SDK versions
- Consult A2A Protocol Specification
- Main README - This file
- Design Document - Architecture and design decisions
- Requirements Document - Detailed requirements
- Java Implementation
- Python Implementation
- JavaScript Implementation
- C# Implementation
- Go Implementation
- Test Suite README - Overview of test suite
- Quick Start Guide - Get started with testing
- Testing Guide - Comprehensive testing guide
- Architecture - Test suite architecture
Start Python Agent:
cd aloha-a2a/aloha-python/agent
python -m agentRun Java Host:
cd aloha-a2a/aloha-java/host
mvn compile exec:java -Dexec.args="--transport rest --port 11002 --message 'Roll a 6-sided dice'"Expected Output:
Connecting to agent at localhost:11002 using REST transport...
Sending message: Roll a 6-sided dice
Response:
I rolled a 6-sided dice and got: 4
Start Go Agent:
cd aloha-a2a/aloha-go/agent
./agentRun Python Host:
cd aloha-a2a/aloha-python/host
python -m host --transport grpc --port 13000 --message "Check if 2, 4, 7, 9, 11 are prime"Expected Output:
Connecting to agent at localhost:13000 using gRPC transport...
Sending message: Check if 2, 4, 7, 9, 11 are prime
Response:
The prime numbers are: 2, 7, 11
Start C# Agent:
cd aloha-a2a/aloha-csharp/Agent
dotnet runRun JavaScript Host:
cd aloha-a2a/aloha-js/host
npm start -- --transport rest --port 14002 --message "Roll a 12-sided dice and check if the result is prime"Expected Output:
Connecting to agent at localhost:14002 using REST transport...
Sending message: Roll a 12-sided dice and check if the result is prime
Response:
I rolled a 12-sided dice and got: 7
7 is a prime number!
Start Java Agent:
cd aloha-a2a/aloha-java/agent
mvn compile quarkus:devRun Python Host with Streaming:
cd aloha-a2a/aloha-python/host
python -m host --transport grpc --port 13000 --message "Roll a 20-sided dice" --streamExpected Output:
Connecting to agent at localhost:13000 using gRPC transport...
Sending message: Roll a 20-sided dice
[Status Update] Task submitted
[Status Update] Processing request...
[Status Update] Invoking roll_dice tool...
[Status Update] Task completed
Final Response:
I rolled a 20-sided dice and got: 17
Query Agent Card:
# Java agent
curl http://localhost:11002/.well-known/agent-card.json | jq
# Python agent
curl http://localhost:13002/.well-known/agent-card.json | jqExpected Output:
{
"name": "Dice Agent",
"description": "An agent that can roll arbitrary dice and check prime numbers",
"url": "localhost:11002",
"version": "1.0.0",
"capabilities": {
"streaming": true,
"pushNotifications": false
},
"skills": [
{
"id": "roll-dice",
"name": "Roll Dice",
"description": "Rolls an N-sided dice",
"examples": ["Roll a 20-sided dice"]
},
{
"id": "check-prime",
"name": "Prime Checker",
"description": "Checks if numbers are prime",
"examples": ["Is 17 prime?"]
}
]
}To validate the A2A multi-language implementation:
-
Start each agent and verify it responds:
# Example: Test Python agent curl http://localhost:11012/.well-known/agent-card.json -
Test cross-language communication by running a host in one language against an agent in another:
# Example: Python host → Java agent cd aloha-a2a/aloha-python/host python -m host --transport rest --port 11002 --message "Roll a dice" # Example: Java host → Python agent cd aloha-a2a/aloha-java/host mvn exec:java -Dexec.args="--transport rest --port 13002 --message 'Roll a dice'"
-
Run the comprehensive test suite (see Testing section below)
The test-suite/ directory contains a comprehensive testing framework that validates all 75 combinations (5 languages × 5 languages × 3 transports).
cd aloha-a2a/test-suite
pip install -e .
./run_tests.sh all- 75 test combinations: 5 languages × 5 languages × 3 transports
- 10 test scenarios per combination: 750 total tests
- Automated agent lifecycle management: Agents start/stop automatically
- Comprehensive reporting: JSON, Markdown, and HTML reports
- Compatibility matrices: Visual representation of working combinations
- Performance metrics: Response time analysis
Test all transports:
python -m src.cli --transport all --output test-resultsTest JSON-RPC only:
python -m src.cli --transport json-rpc --output test-results/json-rpcTest gRPC only:
python -m src.cli --transport grpc --output test-results/grpcTest REST only:
python -m src.cli --transport rest --output test-results/restEach combination runs these 10 scenarios:
- Basic Message Exchange - Simple dice roll request
- Streaming Response - Monitor real-time status updates
- Tool Invocation - Verify tool execution
- Multi-Tool Execution - Multiple tools in one request
- Prime Validation - Complex logic validation
- Task Cancellation - Cancel ongoing operations
- Session Continuity - Multiple messages in same context
- Error Handling - Graceful error handling
- Agent Card Discovery - Agent metadata retrieval
- Protocol Compliance - A2A protocol validation
Results are saved in multiple formats:
test-results/
├── summary.json # Overall summary
├── REPORT.md # Markdown report
├── report.html # HTML report (open in browser)
├── java-host_python-agent_grpc.json # Individual test results
├── python-host_java-agent_rest.json
└── ... (75 result files)
Cross-Language Interoperability Test Results
============================================
Overall Statistics:
Total Test Combinations: 75
Passed: 75
Failed: 0
Success Rate: 100.0%
By Transport Protocol:
JSON-RPC 2.0: 25/25 (100.0%)
gRPC: 25/25 (100.0%)
REST: 25/25 (100.0%)
By Language (as Agent):
Java: 15/15 (100.0%)
Python: 15/15 (100.0%)
JavaScript: 15/15 (100.0%)
C#: 15/15 (100.0%)
Go: 15/15 (100.0%)
Average Response Times:
JSON-RPC 2.0: 1.2s
gRPC: 0.8s
REST: 1.5s
- Test Suite README - Overview and installation
- Quick Start Guide - Get started quickly
- Testing Guide - Comprehensive guide
- Architecture - Technical architecture
See individual language directories for unit testing instructions:
- Java:
mvn test - Python:
pytest - JavaScript:
npm test - C#:
dotnet test - Go:
go test ./...
- Implement All Transport Protocols: Support JSON-RPC, gRPC, and REST for maximum compatibility
- Provide Agent Cards: Always serve agent metadata at
/.well-known/agent-card.json - Support Streaming: Implement streaming for real-time status updates
- Handle Errors Gracefully: Return descriptive error messages following A2A protocol
- Log Important Events: Log server startup, requests, and errors
- Validate Input: Validate all incoming requests before processing
- Use Official SDKs: Use official A2A SDKs for protocol compliance
- Handle Streaming: Process streaming responses for better user experience
- Implement Timeouts: Set appropriate timeouts for requests
- Retry on Failure: Implement retry logic with exponential backoff
- Discover Capabilities: Query agent card before sending requests
- Maintain Context: Use contextId for conversation continuity
- Handle Errors: Gracefully handle connection and protocol errors
- Test All Transports: Verify your implementation works with all three transports
- Test Cross-Language: Test with agents/hosts in different languages
- Test Error Cases: Verify error handling with invalid inputs
- Test Streaming: Verify streaming responses work correctly
- Test Performance: Measure and optimize response times
- Use Test Suite: Run the comprehensive test suite before deployment
Contributions are welcome! To contribute:
- Fork the Repository: Create your own fork
- Create a Branch:
git checkout -b feature/your-feature - Follow Code Style: Match the existing code style for each language
- Add Tests: Include tests for new features
- Update Documentation: Update READMEs and comments
- Run Tests: Ensure all tests pass
- Submit Pull Request: Create a PR with a clear description
- Java: Follow Google Java Style Guide
- Python: Follow PEP 8, use type hints
- JavaScript: Use TypeScript, follow Airbnb style guide
- C#: Follow Microsoft C# coding conventions
- Go: Follow Effective Go guidelines
When adding new features:
- Update the design document
- Implement in all five languages
- Add tests to the test suite
- Update all relevant READMEs
- Ensure cross-language compatibility
- Multi-language implementations (Java, Python, JavaScript, C#, Go)
- Multi-transport support (JSON-RPC, gRPC, REST)
- Streaming communication
- Agent card discovery
- Cross-language interoperability test suite
- Comprehensive documentation
- Authentication and authorization
- TLS/SSL support for all transports
- Rate limiting
- Metrics and monitoring
- Docker containers for easy deployment
- Kubernetes deployment examples
- Additional example agents (weather, calculator, etc.)
- Performance benchmarking suite
- CI/CD pipeline for automated testing
See the main repository LICENSE file.
- A2A Protocol Specification - Protocol definition
- A2A SDK maintainers for official SDKs
- Contributors to this project
For questions, issues, or contributions:
- Check the documentation
- Review troubleshooting section
- Search existing issues
- Create a new issue with details
- Join community discussions
Happy coding with A2A! 🚀