This repository contains sample applications demonstrating how to use the A2A Ruby SDK to build agent-to-agent communication systems.
The Agent2Agent (A2A) Protocol enables seamless communication between AI agents across different platforms, languages, and frameworks. This Ruby implementation is part of the broader A2A ecosystem.
- A2A Protocol Specification - Official A2A specification and documentation
- A2A Ruby SDK - Ruby implementation of the A2A protocol (this gem)
- A2A Python SDK - Official Python implementation
- A2A Samples - Multi-language sample repository with Python, JavaScript, Go, and Java examples
- A2A Inspector - UI tool for inspecting A2A-enabled agents
The a2a-ruby gem provides:
- β Full A2A Protocol Compliance - Implements the complete A2A v0.3.0 specification
- β Cross-Language Compatibility - Works seamlessly with Python, JavaScript, and other A2A implementations
- β Production Ready - Clean, well-tested Ruby implementation
- β Easy Integration - Simple API for building A2A-enabled agents
- β JSON-RPC 2.0 Support - Standard protocol for method calls and responses
All sample applications are working perfectly with the published A2A Ruby gem:
- β Published Gem - Uses stable v1.0.0 release from RubyGems.org
- β JSON-RPC Method Calls - All method calls work correctly
- β Cross-Stack Compatible - Works with Python A2A agents
- β Production Ready - Clean dependencies and stable operation
- Ruby 2.7+ and Bundler
- Git (for cloning repositories)
# Clone and setup samples
git clone https://github.com/traylinx/a2a-ruby-samples.git
cd a2a-ruby-samples
./setup.shThe samples use the published A2A Ruby gem from RubyGems.org, so no separate gem installation is needed. Bundler will handle all dependencies automatically.
-
Start the Hello World agent:
cd samples/helloworld-agent ruby server.rb -
Test with the client:
# In another terminal ruby client.rb -
Try interactive mode:
ruby client.rb --interactive
The simplest possible A2A agent that responds with "Hello World!"
- Tech: Plain Ruby
- Features: Basic agent setup, simple message handling
- Use Case: Learning A2A basics
Interactive agent that rolls dice and checks for prime numbers
- Tech: Plain Ruby with tools
- Features: Function calling, interactive responses, state management
- Use Case: Game mechanics, interactive agents
Practical weather service agent with real API integration
- Tech: Plain Ruby with external APIs
- Features: External service integration, error handling, caching
- Use Case: Service integration, real-world data
- Ruby 2.7.0 or higher
- Bundler gem manager
- OpenWeatherMap API key (for weather agent)
# 1. Clone the repository
git clone https://github.com/traylinx/a2a-ruby-samples.git
cd a2a-ruby-samples
# 2. Run setup script
./setup.sh
# 3. Configure weather agent (optional)
cd samples/weather-agent
cp .env.example .env
# Edit .env and add your OpenWeatherMap API keyEach sample includes:
README.md- Specific setup instructionsGemfile- Dependenciesserver.rb- Agent serverclient.rb- Test clientspec/- Unit tests
cd samples/helloworld-agent
ruby server.rb
# In another terminal: ruby client.rbcd samples/dice-agent
ruby server.rb
# Test with: ruby client.rb --interactivecd samples/weather-agent
# Configure API key in .env first
ruby server.rb
# Test with: ruby client.rb --interactiveThis repository includes a comprehensive test suite that validates all A2A functionality:
# Run complete test suite (28 tests covering all functionality)
./test_all_agents.shTest Coverage:
- β 28 Tests Total - 100% pass rate
- β HTTP Endpoints - Health checks, agent cards, web interfaces
- β JSON-RPC Methods - All 12 A2A methods across 3 agents
- β Error Handling - Invalid methods, parameters, and edge cases
- β Batch Requests - Multiple JSON-RPC calls in single request
- β Mock Mode - Weather agent works without API keys
- β Cross-Stack Compatibility - Verified with Python implementations
# Test all samples individually
./test_samples.sh
# Test cross-stack compatibility
./test_cross_stack.sh
# Run all tests including unit tests
./test_all.sh# Run tests for specific sample
cd samples/dice-agent
bundle exec rspec
# Run tests for all samples
./test_all.shTest Ruby agents with other language implementations from the official A2A samples:
# 1. Clone the official A2A samples repository
git clone https://github.com/a2aproject/a2a-samples.git
# 2. Start Ruby Hello World agent
cd a2a-ruby-samples/samples/helloworld-agent
ruby server.rb &
# 3. Test with Python client
cd ../../a2a-samples/samples/python/agents/helloworld
uv run test_client.py
# 4. Cleanup
kill %1# 1. Start Python Hello World agent
cd a2a-samples/samples/python/agents/helloworld
uv run . &
# 2. Test with Ruby client
cd ../../../a2a-ruby-samples/samples/helloworld-agent
AGENT_URL=http://localhost:9999/a2a ruby client.rb
# 3. Cleanup
kill %1The A2A samples repository includes implementations in:
- Python - Full-featured agents with various frameworks (LangGraph, CrewAI, etc.)
- JavaScript - Node.js and browser-based agents
- Go - High-performance agent implementations
- Java - Enterprise-ready agent solutions
All implementations are fully interoperable with these Ruby samples.
Most samples include Docker support:
cd samples/helloworld-agent
docker-compose up- A2A Ruby SDK - Main gem repository and documentation
- A2A Ruby API Documentation - Detailed API reference
- A2A Protocol Specification - Official protocol documentation
- A2A Samples Repository - Multi-language examples and tutorials
- A2A Inspector - Agent debugging and inspection tool
- Quick Start Guide - Ruby-specific quick start
- Protocol Overview - Understanding A2A fundamentals
- Fork the repository
- Create a feature branch
- Add your sample application
- Include comprehensive README and tests
- Submit a pull request
samples/your-sample/
βββ README.md # Setup and usage instructions
βββ Gemfile # Dependencies
βββ server.rb # Agent server implementation
βββ client.rb # Test client
βββ spec/ # Tests
βββ docker-compose.yml # Container setup (optional)
βββ .env.example # Environment variables
These Ruby samples are designed to be fully compatible with all A2A implementations, enabling seamless cross-language agent communication. You can test interoperability with the official A2A samples repository which includes Python, JavaScript, Go, and Java implementations.
| Ruby Agent | Other Language Clients | Status |
|---|---|---|
| Hello World | Python, JavaScript, Go, Java | β Compatible |
| Dice Agent | Python, JavaScript, Go, Java | β Compatible |
| Weather Agent | Python, JavaScript, Go, Java | β Compatible |
| Other Language Agents | Ruby Client | Status |
|---|---|---|
| Python Agents | All samples | β Compatible |
| JavaScript Agents | All samples | β Compatible |
| Go Agents | All samples | β Compatible |
| Java Agents | All samples | β Compatible |
All samples implement:
- β JSON-RPC 2.0 specification compliance
- β A2A Protocol v0.3.0 compliance
- β Agent Card schema compatibility
- β Message format standardization
- β Task lifecycle compatibility
- β Error handling standardization
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: A2A Ruby SDK Issues
- Discussions: A2A Ruby Discussions
- Documentation: A2A Ruby SDK Docs
- Protocol Issues: A2A Specification Issues
- Multi-Language Examples: A2A Samples Issues
- Community: A2A Project Discussions
Happy coding with A2A Ruby! π