Repository navigation
feat(rig-a2a): serve agents over the A2A protocol - #2820
Closed
gold-silver-copper wants to merge 2 commits into
Closed
gold-silver-copper wants to merge 2 commits into
gold-silver-copper wants to merge 2 commits into
Conversation
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]>
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-lf0.4 anda2a-server-lf0.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 RigAgentinto an A2A agent executor and an Axum router.Exposing an agent is a few lines:
What the router serves:
/.well-known/agent-card.json(name and description from the agent, both bindings, streaming on, push off, onechatskill;edit_cardchanges anything);/jsonrpc:SendMessage,SendStreamingMessage(SSE),GetTask,ListTasks,CancelTask,SubscribeToTask;/rest:POST /message:send,POST /message:stream,GET /tasks/{id},POST /tasks/{id}:cancel, and the rest.Behavior (
A2aExecutor):Task, text deltas append to oneresponseartifact, 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 endscompleted,failed(error logged, generic message to the client), orrejectedfor a part Rig cannot read.contextIdshare the agent's Rig conversation history, including tool calls and results, kept in memory for the life of the server.CancelTaskaborts the running agent stream, so the model call or tool stops.text/plainandapplication/jsonby default, and the router passes the card's input modes to the SDK, which refuses other declared media types withContentTypeNotSupportedError.Wiring: workspace member,
rig::a2abehind the facade'sa2afeature (docs.rs list and the facade additivity fixture updated), a README row, and the same native-only gate asrig-rmcp: onecompile_error!on wasm, with anative-only-rig-a2aCI check.Closes #391
Changelog
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 asrig::a2awith thea2afeature (native targets only).Migration
None.
Type of change
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-a2awith-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.cargo run -p rig-a2a --example a2a_serverwith a real OpenAI model (gpt-5.4-mini) and talked to it with the official A2A Python SDK (a2a-sdk1.2.2, an independent implementation): a streamed message over JSON-RPC (taskWORKING, 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 withcurl, and checked that a request withoutA2A-VersiongetsVERSION_NOT_SUPPORTED.Checklist:
CHANGELOG.mdorMIGRATING.md(they are generated at release)Notes
tasks/send, latermessage/sendandmessage/stream). A2A 1.0 renamed them toSendMessage,SendStreamingMessage,GetTaskandCancelTask, and requires theA2A-Version: 1.0header; this crate speaks 1.0 only, as the SDK does.From<Agent>for the a2a crate's agent type, plus an example") maps toA2aExecutor::new(agent), the SDK's executor trait implemented for a Rig agent, andA2aServeron top. Skillexamples(feat: Examples trait #784, now closed) are left toedit_card, since agents carry no examples.referenceTaskIds. The first three are available by building the SDK'sDefaultRequestHandleraroundA2aExecutor; the README says so.a2a-lf0.4,a2a-server-lf0.5, and the dev-onlya2a-client-lf0.2.6 (its first release ona2a-lf0.4).Co-authored-by: Nikhil Pandey [email protected]
Co-authored-by: Joshua Mo [email protected]