Skip to main content

Module failure

Module failure 

Source
Expand description

Why a task failed, as something a caller can match on.

§The gap this closes

A failed task is TaskState::Failed plus an error message: prose, written by whoever wrote the executor. A caller deciding what to do next is matching English.

The decisions are genuinely different, and getting them wrong is visible as bad agent behaviour to whoever is watching:

ClassWhat a caller should do
InvalidRequestNever retry. Fix the request.
TransientRetry with backoff.
PolicyRefusalStop and escalate to a human.
BudgetExhaustedRetry with more budget, or not at all.
InternalThe agent broke. Retry once, then escalate.

Without this an orchestrator either retries what can never succeed or abandons what would have worked on the second attempt.

§Wire shape

Not part of A2A v1.0, so it ships as the declared extension https://a2a-rust.com/extensions/failure/v1. Message.extensions is a list of URIs and cannot carry a value, so the class travels in Message.metadata under a2a-rust.com/failure while extensions declares the URI — the same split idempotency uses, for the same reason.

It rides on the status message of the failed task, which is the spec’s field for “additional status updates for the client” and the one place a caller already looks when a task fails.

An unrecognised class reads as FailureClass::Internal rather than an error. A peer that classifies more finely than this enum should not make its failures unreadable, and “something went wrong at the agent” is true of every class a future version could add.

use a2a_protocol_types::failure::{FailureClass, class_of, set_class};
use a2a_protocol_types::message::Message;

let mut status = Message::agent_text("m1", "upstream model refused the prompt");
set_class(&mut status, FailureClass::PolicyRefusal);

assert_eq!(class_of(&status), Some(FailureClass::PolicyRefusal));
assert!(!class_of(&status).expect("set above").is_retryable());

Enums§

FailureClass
What kind of failure a task ended in.

Constants§

FAILURE_EXTENSION_URI
The extension URI a card declares and a message names in extensions.
FAILURE_METADATA_KEY
The Message.metadata key the class travels under.

Functions§

class_of
Reads the class off a status message, if one was recorded.
declares_extension
Whether a message declares the failure extension in extensions.
error_class
The class a failed task gets when its executor returned error.
set_class
Records the class on a status message, declaring the extension URI.
set_error_class
Records a class on an error, for an executor that fails by returning Err rather than by emitting its own Failed status.