Skip to main content

Module a2a

Module a2a 

Source
Expand description

A2A (Agent2Agent) 1.0 server, JSON-RPC binding (18.17.0, #65): other agents discover this one by its Agent Card at /.well-known/agent-card.json and talk to it with SendMessage, GetTask, ListTasks, CancelTask.

use rust_web_server::a2a::{A2aReply, A2aServer, AgentCard, Artifact, Message, Skill};

let agent = A2aServer::new(
    AgentCard::new("Echo agent", "Repeats what you say", "1.0.0")
        .skill(Skill::new("echo", "Echo", "Repeats the message").tag("demo")),
)
.on_message(|ctx, message| {
    if message.text().is_empty() {
        return A2aReply::Message(Message::agent_text("Say something."));
    }
    A2aReply::Task(ctx.complete(vec![Artifact::text("echo", message.text())]))
});

Mount it beside your routes with A2aServer::wrap; it answers the card and POST at its path (default /a2a) and passes everything else on.

Structs§

A2aContext
What a message handler sees besides the message.
A2aServer
The A2A server: an Application serving the Agent Card and the JSON-RPC endpoint.
AgentCard
The agent’s self-description, served at AGENT_CARD_PATH.
Artifact
An output of a task.
Message
A message between a client and an agent.
Part
One piece of a message or artifact: exactly one of text, raw bytes, a URL or structured data, with an optional media type and file name.
Skill
Something the agent can do, as listed on its card.
Task
A unit of work the agent tracks.
TaskHandle
A task being worked on in the background: keep it (it’s Clone and Send), report progress, and finish it. Updates after the task finished (or was canceled) are ignored.
TaskStatus
A task’s state with an optional message and when it was set.

Enums§

A2aReply
A handler’s answer to a message.
PartContent
What a Part holds.
Role
Who sent a message.
TaskState
A task’s state.

Constants§

AGENT_CARD_PATH
Where the Agent Card is served.
MAX_BODY
Request bodies larger than this are refused.
MAX_TASKS
Tasks kept (oldest dropped first).
PROTOCOL_VERSION
The protocol version served (A2A-Version).