Examples Overview

The examples/ directory holds sixteen crates: fifteen runnable examples that show the a2a-rust SDK doing real work, and harness, the library several of them share to score their coverage. Each is a workspace member that depends on the SDK by path, so run it from the repository root. Use this page to pick one: the table says what each shows and what it needs, and the learning path below it says what order to read them in.

Choose an example

"Nothing" means a plain cargo run needs no model, key, service or other language. The package name is not always the directory name; each page gives the exact command.

ExampleWhat it showsNeedsLevel
Hello AgentThe smallest complete agent: an executor, a card and a JSON-RPC listener in one file, using only the SDK's preludeNothingBeginner
Echo AgentEvery A2A method over all four bindings from one handler, with a coverage matrix that fails the run on a gap, and counter-tests for the calls that must be refusedNothingBeginner
Deploy AgentThe hello agent made shippable: environment configuration, /health and /ready, SIGTERM draining, a container and a Kubernetes manifestNothing locally; Docker or Kubernetes to deploy; PostgreSQL for more than one replicaBeginner
Incident-Response TeamThree agents handling an incident: multi-turn INPUT_REQUIRED, delegation, streaming progress, cancellation; then the coverage matrix and sixteen production-hardening checksNothing; a local model or an API key, optionally; PostgreSQL for one checkIntermediate
Agent TeamThe SDK's dogfood suite: five agents over JSON-RPC, REST and gRPC plus a sixth serving all four bindings, 100 end-to-end tests and a 2-result method × binding sweep, 102 on the default feature setNothingAdvanced
Resilient AgentWhat survives a restart, a failure and a second replica, each asserted, with what the SDK does not do asserted tooNothing; PostgreSQL for two of its eight checksAdvanced
Genai AgentAn LLM-backed agent through genai (OpenAI, Anthropic, Gemini, local servers and others), on all four bindings with the coverage matrixNothing for the self-check, which labels its answers as fallbacks; a local model server or an API key for real answersIntermediate
Rig AgentA rig-core agent with a bounded tool loop behind A2A, showing where tool calling sits relative to the protocolNothing for the conformance run; a tool-capable model, local or hosted, to see a tool callIntermediate
Tool-Loop AgentTool calling from the SDK alone: ToolLoopExecutor over OpenAiChatModel, no loop writtenAn OpenAI-compatible model server (cargo test needs none)Intermediate
Live ModelThe SDK end to end against a real model: ten checks across four bindings, provenance, idempotency, a budget, a halt and a two-approver quorumAn OpenAI-compatible model serverAdvanced
MCP AgentAn agent whose tools come from an MCP server it discovers at startupNothing; a tool-capable model to exercise the MCP legIntermediate
A2A → MCP BridgeA remote A2A agent exposed as an MCP server, callable as a toolNothingIntermediate
Langfuse AgentTwo agents in one Langfuse trace, exported by the SDK's own Telemetry with no tracing code in either agentA Langfuse: self-hosted with Docker Compose, or a Langfuse Cloud project's keysIntermediate
Multi-Language TeamA Rust coordinator fanning out to Python, JavaScript, Go, Java and Rust workersNothing with the Rust worker; Python, Node.js, Go or Java for the others, optionallyAdvanced
SwarmA coordinator, supervisors and workers, every hop a real A2A call: fan-out, retry by failure class, cancellation through two hopsNothing; a model for one optional scenarioAdvanced
Example Harness and Go InteropThe library that scores the coverage matrix for six of the examples, and a check of this SDK against the official Go SDK in both directionsNothing for its tests; Go for scripts/go_sdk_interop.shReference

A learning path

  1. Hello Agent. The whole agent fits on one screen: the executor, the card, the listener.
  2. Echo Agent. The same idea over all four bindings and every method, and how this project checks a claim of coverage.
  3. Incident-Response Team. The recommended first multi-agent example: a task that pauses for input, delegates, streams and can be cancelled.
  4. Then branch by what you are building:

Telemetry in every example

Every example binary that runs A2A code starts the SDK's Telemetry from the OTEL_* environment: with OTEL_EXPORTER_OTLP_ENDPOINT set it exports traces, metrics and logs over OTLP, and without it nothing is built, so a plain cargo run needs no collector. OTEL_TRACES_EXPORTER=console (and the metrics and logs equivalents) prints the signal instead. examples/README.md describes every example from the repository's side.

Common pattern

Every example that serves A2A follows the same three-step integration pattern:

fn card() -> a2a_protocol_types::agent_card::AgentCard {
    use a2a_protocol_types::agent_card::{AgentCapabilities, AgentCard, AgentInterface, AgentSkill};
    AgentCard::new("my-agent", "1.0.0", AgentInterface::jsonrpc("http://localhost:3000"))
        .with_description("An example agent")
        .with_skill(AgentSkill::new("echo", "Echo", "Echoes text").with_tags(["echo"]))
        .with_capabilities(AgentCapabilities::none().with_streaming(true))
}
use a2a_protocol_sdk::prelude::*;
use std::sync::Arc;

// 1. Implement AgentExecutor. The macro writes the impl; the trait's real
//    signature returns Pin<Box<dyn Future>> to stay object-safe.
struct MyExecutor;

agent_executor!(MyExecutor, |ctx, queue| async {
    let emit = EventEmitter::new(ctx, queue);
    emit.status(TaskState::Working).await?;
    // ... do work ...
    emit.artifact("result", vec![Part::text("done")], None, Some(true)).await?;
    emit.status(TaskState::Completed).await?;
    Ok(())
});

fn main() -> Result<(), Box<dyn std::error::Error>> {
// 2. Build a handler
let handler = Arc::new(RequestHandlerBuilder::new(MyExecutor).with_agent_card(card()).build()?);

// 3. Serve via any dispatcher
let dispatcher = JsonRpcDispatcher::new(handler);
// or: RestDispatcher, RestRouter (Axum), gRPC
let _ = dispatcher;
Ok(())
}

For details on each step, see The AgentExecutor Trait, Request Handler & Builder, and Dispatchers.