Skip to main content

Module approval

Module approval 

Source
Expand description

An agent asking a person before it acts, and the person’s answer bound to exactly what was asked.

§The gap this closes

A2A can already pause a task for a person: the agent moves it to input-required, and someone answers with a message. What it cannot say is what is being approved, who may approve it, or whether the answer was to this question or an earlier one. An “OK” in free text approves whatever the agent does next.

§Wire shape

Not part of A2A v1.0, so it ships as the declared extension https://a2a-rust.com/extensions/approval/v1, in the same style as failure: values in Message.metadata under a2a-rust.com/approval, the URI in Message.extensions.

  • The request rides on the status message of the input-required task: an id, a one-line summary for the person, and the SHA-256 digest of the action’s canonical JSON (the exact tool call, payment, or command the agent will run), plus who started the run that asks.
  • The decision rides on the message that continues the task: the request id, approve or deny, and the digest the approver was shown.

A server that installs the gate checks the decision before the executor sees it: the request is the one pending on the task, the digest matches, and the approver is authenticated, allowed, and (by default) not the person whose run asked. A digest that does not match means the approver was shown something other than what the agent will do, and the decision is refused.

use a2a_protocol_types::approval::{ApprovalDecision, ApprovalRequest, Decision};
use a2a_protocol_types::message::Message;

let request = ApprovalRequest::new("req-1", "Refund EUR 40 to order 1182", "sha256:ab12");
let mut ask = Message::agent_text("m1", "Approve this refund?");
request.attach(&mut ask);
assert_eq!(ApprovalRequest::read(&ask).unwrap(), Some(request.clone()));

let mut answer = Message::user_text("m2", "yes");
ApprovalDecision::approve(&request).attach(&mut answer);
let decision = ApprovalDecision::read(&answer).unwrap().expect("attached above");
assert_eq!(decision.decision, Decision::Approve);
assert_eq!(decision.digest, request.digest);

Structs§

ApprovalDecision
A person’s answer to an ApprovalRequest.
ApprovalRequest
What an agent asks a person to approve.

Enums§

Decision
The answer.

Constants§

APPROVAL_EXTENSION_URI
The extension URI a card declares and a message names in extensions.
APPROVAL_METADATA_KEY
The Message.metadata key a request or decision travels under.

Functions§

action_digestsigning
sha256:<hex> over the RFC 8785 canonical JSON of action: what an agent puts in ApprovalRequest::digest.