Skip to content

feat(rig-a2a): serve agents over the A2A protocol - #2820

Closed
gold-silver-copper wants to merge 2 commits into
mainfrom
triage/a2a
Closed

gold-silver-copper wants to merge 2 commits into
mainfrom
triage/a2a

Conversation

@gold-silver-copper

Copy link
Copy Markdown
Collaborator

feat(rig-a2a): serve agents over the A2A protocol

Description

Adds rig-a2a, a companion crate that serves a Rig agent over the Agent2Agent (A2A) protocol, version 1.0 (spec release v1.0.1: specification, proto schema).

It builds on the official A2A Rust SDK from the Linux Foundation project (a2aproject/a2a-rs: a2a-lf 0.4 and a2a-server-lf 0.5) instead of re-implementing the protocol. The SDK owns the wire formats, the JSON-RPC and HTTP+JSON bindings, SSE, version negotiation and the task store; this crate turns a Rig Agent into an A2A agent executor and an Axum router.

Exposing an agent is a few lines:

use rig_a2a::A2aServer;

let app = A2aServer::new(agent, "http://localhost:3000").into_router();
let listener = tokio::net::TcpListener::bind("localhost:3000").await?;
rig_a2a::axum::serve(listener, app).await?;

What the router serves:

  • the agent card at /.well-known/agent-card.json (name and description from the agent, both bindings, streaming on, push off, one chat skill; edit_card changes anything);
  • JSON-RPC at /jsonrpc: SendMessage, SendStreamingMessage (SSE), GetTask, ListTasks, CancelTask, SubscribeToTask;
  • HTTP+JSON at /rest: POST /message:send, POST /message:stream, GET /tasks/{id}, POST /tasks/{id}:cancel, and the rest.

Behavior (A2aExecutor):

  • Each message starts a task. The stream begins with the Task, text deltas append to one response artifact, and the final answer replaces them (append: false, lastChunk: true), since a multi-turn run can stream text before tool calls or in a retried turn. The task ends completed, failed (error logged, generic message to the client), or rejected for a part Rig cannot read.
  • Messages sharing a contextId share the agent's Rig conversation history, including tool calls and results, kept in memory for the life of the server.
  • CancelTask aborts the running agent stream, so the model call or tool stops.
  • Parts map to Rig user content: text and data as text, file bytes and URLs as image, audio, video or document content by media type. The card accepts text/plain and application/json by default, and the router passes the card's input modes to the SDK, which refuses other declared media types with ContentTypeNotSupportedError.

Wiring: workspace member, rig::a2a behind the facade's a2a feature (docs.rs list and the facade additivity fixture updated), a README row, and the same native-only gate as rig-rmcp: one compile_error! on wasm, with a native-only-rig-a2a CI check.

Closes #391

Changelog

  • (rig-a2a) New crate: serve a Rig agent over the A2A protocol 1.0 with A2aServer::new(agent, url).into_router(), built on the official A2A Rust SDK; JSON-RPC and HTTP+JSON bindings, SSE streaming, task get, list and cancel, and per-context conversation history. Available in the facade as rig::a2a with the a2a feature (native targets only).

Migration

None.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Testing

  • cargo nextest run --locked --profile local -p rig-a2a: 4 tests pass. The integration tests serve a scripted agent on a loopback port and drive it with the official Rust client (a2a-client-lf): streamed message, GetTask, a follow-up in the same context over JSON-RPC and then over HTTP+JSON (the model receives the whole context history), cancel of a task blocked in a tool call, a refused media type, and a rejected untyped file URL. A unit test covers part conversion.
  • cargo clippy -p rig-a2a --all-targets -- -D warnings, cargo doc -p rig-a2a with -D warnings, cargo test -p rig-a2a --doc, cargo check -p rig --features a2a --lib, cargo xtask check-packaging, cargo xtask check-test-layout, cargo xtask verify --check native-only-rig-a2a, cargo fmt --check.
  • Real-app check: ran cargo run -p rig-a2a --example a2a_server with a real OpenAI model (gpt-5.4-mini) and talked to it with the official A2A Python SDK (a2a-sdk 1.2.2, an independent implementation): a streamed message over JSON-RPC (task WORKING, 28 appended deltas, the final replacing chunk, COMPLETED), a follow-up in the same context ("What did I just ask you?" answered "You asked what the A2A protocol is."), GetTask, then the same over HTTP+JSON without streaming. Also fetched the card and streamed a message with curl, and checked that a request without A2A-Version gets VERSION_NOT_SUPPORTED.
  • Codex review (GPT-6.1 Sol, fast, high effort): 1 round, no findings.

Checklist:

  • I have updated READMEs and Rust docs affected by this change
  • I have added tests that prove my fix is effective or that my feature works
  • I did not edit CHANGELOG.md or MIGRATING.md (they are generated at release)

Notes

  • The issue thread and the maintainer's prototype (joshua-mo-143/a2a) used pre-1.0 method names (tasks/send, later message/send and message/stream). A2A 1.0 renamed them to SendMessage, SendStreamingMessage, GetTask and CancelTask, and requires the A2A-Version: 1.0 header; this crate speaks 1.0 only, as the SDK does.
  • The maintainer's later scope ("From<Agent> for the a2a crate's agent type, plus an example") maps to A2aExecutor::new(agent), the SDK's executor trait implemented for a Rig agent, and A2aServer on top. Skill examples (feat: Examples trait #784, now closed) are left to edit_card, since agents carry no examples.
  • Not built in: push notifications, authentication, gRPC, persistent conversation history, and use of referenceTaskIds. The first three are available by building the SDK's DefaultRequestHandler around A2aExecutor; the README says so.
  • Dependency floors: a2a-lf 0.4, a2a-server-lf 0.5, and the dev-only a2a-client-lf 0.2.6 (its first release on a2a-lf 0.4).

Co-authored-by: Nikhil Pandey [email protected]
Co-authored-by: Joshua Mo [email protected]

gold-silver-copper and others added 2 commits October 15, 2026 07:29
Add rig-a2a, a companion crate that serves a Rig agent over the
Agent2Agent protocol, version 1.0, on top of the official A2A Rust SDK
(a2a-lf and a2a-server-lf). A2aServer builds the agent card and an Axum
router with the JSON-RPC and HTTP+JSON bindings, SSE streaming, and task
get, list and cancel. A2aExecutor maps messages to Rig user content,
streams the reply into a text artifact, keeps each context's
conversation history, and drops a run when its task is canceled.

The facade exposes it as rig::a2a behind the `a2a` feature. The crate is
native-only and raises one compile_error! on wasm, checked in CI.

Co-authored-by: Nikhil Pandey <[email protected]>
Co-authored-by: Joshua Mo <[email protected]>
Co-authored-by: Nikhil Pandey <[email protected]>
Co-authored-by: Joshua Mo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Support exposing Agents via A2A protocol

1 participant