Skip to main content

Crate rig_a2a

Crate rig_a2a 

Source
Expand description

Rig agents over the Agent2Agent (A2A) protocol, version 1.0, both ways: serve a Rig Agent to any A2A client with A2aServer, and call any A2A agent from a Rig agent as a tool with RemoteAgent.

A2aServer builds the agent card and an Axum router with the JSON-RPC and HTTP+JSON bindings, streaming over server-sent events, and task get, list and cancel. The protocol itself comes from the official A2A Rust SDK, re-exported as a2a and a2a_server.

Each message starts a task. The reply streams into one text artifact and the task completes, fails, or is canceled. Messages that share a contextId share the agent’s conversation history, which lives in memory for the life of the server. A2aExecutor is the same agent as an a2a_server::AgentExecutor for a handler you assemble yourself.

use rig_a2a::A2aServer;
use rig_agent::AgentBuilder;
use rig_core::providers::openai::{self, OpenAI};
let model = OpenAI::from_env()?.completion(openai::GPT_5_4_MINI);
let agent = AgentBuilder::new(model).name("helper").build();
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?;

Re-exports§

pub use a2a;Non-target_family=wasm
pub use a2a_client;Non-target_family=wasm
pub use a2a_server;Non-target_family=wasm
pub use axum;Non-target_family=wasm
pub use rig_memory;Non-target_family=wasm

Structs§

A2aExecutorNon-target_family=wasm
A Rig Agent as an A2A AgentExecutor.
A2aServerNon-target_family=wasm
A Rig agent served over A2A: its agent card, its task store, and the router into_router builds from them.
RemoteAgentNon-target_family=wasm
An A2A agent reached over the network.
RemoteAgentBuilderNon-target_family=wasm
Options for RemoteAgent: a bearer token and a timeout.
RemoteFileNon-target_family=wasm
A file in an answer.
ReplyNon-target_family=wasm
One answer from a remote agent.

Enums§

FileContentNon-target_family=wasm
Where a RemoteFile’s bytes are.
RemoteErrorNon-target_family=wasm
Why a remote agent could not be reached or did not answer.
ReplyEventNon-target_family=wasm
What RemoteAgent::stream reports while an answer is written.

Constants§

DEFAULT_HISTORY_TOKENSNon-target_family=wasm
How many tokens of history a request sends by default.
DEFAULT_MAX_CONCURRENT_TASKSNon-target_family=wasm
How many tasks run at once by default; more are rejected as busy.
DEFAULT_MAX_CONTEXTSNon-target_family=wasm
How many conversations the in-memory store remembers by default.
DEFAULT_MAX_REQUEST_BYTESNon-target_family=wasm
The largest request body a server reads by default: 2 MiB.
DEFAULT_MAX_RUN_DURATIONNon-target_family=wasm
How long one run may take by default before it is stopped.
DEFAULT_TIMEOUTNon-target_family=wasm
How long a remote agent may stay silent before a call gives up, unless told otherwise: the whole wait without streaming, the gap between two events with it.
JSONRPC_PATHNon-target_family=wasm
The path of the JSON-RPC binding under the server’s base URL.
REST_PATHNon-target_family=wasm
The path of the HTTP+JSON binding under the server’s base URL.
V03_PATHNon-target_family=wasm
Where the v0.3 surface is mounted under the server’s base URL.