agent2agent
A Ruby implementation of Google’s Agent-to-Agent (A2A) protocol — an open standard for interoperable communication between AI agents.
Build A2A-compliant agents that can communicate with any other A2A agent regardless of language or framework. Ships with server and client, both protocol bindings (JSON-RPC 2.0 and HTTP+JSON/REST), SSE streaming, and validated protocol objects for all 47 A2A schema types.
Runs on Falcon + Async — pure fiber-based concurrency, no threads.
Quick start
An agent is a Rack app built from a single handler block. Route operations with pattern matching:
# config.ru
require "a2a"
run A2A.agent(agent_card: { "name" => "Echo Agent", "version" => "1.0.0" }) do |env|
case env["a2a.operation"]
in "SendMessage"
A2A::Protocol::JsonSchema["Send Message Response"].new(
task: {
"id" => "task-1",
"status" => { "state" => "TASK_STATE_COMPLETED" },
"artifacts" => [{ "parts" => [{ "text" => "Echo: #{env["a2a.message"]}" }] }],
}
)
end
end
Head to Getting Started for a complete walkthrough — installing the gem, building a minimal agent, and calling it from both curl and Ruby.
What’s here
- Core Features — the JSON-RPC and REST client bindings, the agent handler, streaming, multi-turn conversations, server and client usage of all 11 protocol operations, handling of every protocol error, and mounting agents in Rails & Rack hosts.
- Advanced — async background jobs, managing task state, schema validation, and distributed tracing.
- Examples — runnable agents from a minimal echo agent up to a full-featured agent and multi-agent orchestration.