Skip to main content

TaskState

Enum TaskState 

Source
#[non_exhaustive]
pub enum TaskState { Unspecified = 0, Submitted = 1, Working = 2, Completed = 3, Failed = 4, Canceled = 5, InputRequired = 6, Rejected = 7, AuthRequired = 8, }
Expand description

Defines the possible lifecycle states of a Task.

On the wire each state is its ProtoJSON name ("TASK_STATE_COMPLETED", spec §5.5); the v0.3 lowercase and kebab-case spellings are accepted on input.

This enum is closed to the v1.0 states. A future protocol revision that adds a state would be a wire-breaking change for the gRPC binding: an unknown TASK_STATE_* number from a newer peer is rejected by the protobuf conversion layer (with a field-scoped error) rather than silently discarded, so no task is ever reported in a bogus state.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Unspecified = 0

The task is in an unknown or indeterminate state.

§

Submitted = 1

Indicates that a task has been successfully submitted and acknowledged.

§

Working = 2

Indicates that a task is actively being processed by the agent.

§

Completed = 3

Indicates that a task has finished successfully. This is a terminal state.

§

Failed = 4

Indicates that a task has finished with an error. This is a terminal state.

§

Canceled = 5

Indicates that a task was canceled before completion. This is a terminal state.

§

InputRequired = 6

Indicates that the agent requires additional user input to proceed. This is an interrupted state.

§

Rejected = 7

Indicates that the agent has decided to not perform the task. This may be done during initial task creation or later once an agent has determined it can’t or won’t proceed. This is a terminal state.

§

AuthRequired = 8

Indicates that authentication is required to proceed. This is an interrupted state.

Implementations§

Source§

impl TaskState

Source

pub const ALL: [TaskState; 9]

Every variant, in declaration order.

TaskState is #[non_exhaustive], so no downstream crate can write an exhaustive match over it. Code that must consider every state — the store retention sweep, which may delete terminal tasks and must never delete anything else — therefore had no way to notice a variant being added, and would have quietly kept treating a new terminal state as non-terminal forever.

all_lists_every_variant below is the guard: an exhaustive match in this crate, where exhaustiveness is enforceable, indexed against this array.

Source

pub const fn is_terminal(self) -> bool

Returns true if this state is a terminal (final) state.

Terminal states: Completed, Failed, Canceled, Rejected.

Source

pub const fn is_interrupted(self) -> bool

Returns true if this state is an interrupted state.

Interrupted states: InputRequired, AuthRequired. Per Section 3.2.2, blocking SendMessage MUST return when the task reaches a terminal OR interrupted state.

Source

pub const fn can_transition_to(self, next: TaskState) -> bool

Returns true if transitioning from self to next is a valid state transition per the A2A protocol.

The specification (§4.1.3) enumerates the task states and classifies them as terminal or interrupted, but it deliberately does not define a transition matrix — it never requires a task to pass through any intermediate state. Two rules follow from what it does say, and they are the only two enforced here:

  1. Terminal states are final. Completed, Failed, Canceled, and Rejected transition nowhere, including to themselves.
  2. Submitted is an entry state. Nothing transitions into it, and nothing transitions into the proto-default Unspecified. Unspecified as a source still transitions anywhere, since a task decoded with no state set must be able to take its real one.

Everything else is permitted. In particular Submitted → Completed is valid: an agent that answers a trivial request in one step never enters Working, and the reference SDKs emit exactly that sequence (the official a2a-tck SUT contract completes straight from Submitted). A stricter table here rejected conformant agents — including this SDK’s own users — with a spurious InvalidParams.

Trait Implementations§

Source§

impl Clone for TaskState

Source§

fn clone(&self) -> TaskState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for TaskState

Source§

impl Debug for TaskState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TaskState

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<TaskState, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for TaskState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for TaskState

Source§

impl From<TaskState> for TaskState

Source§

fn from(value: TaskState) -> TaskState

Converts to this type from the input type.
Source§

impl Hash for TaskState

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TaskState

Source§

fn eq(&self, other: &TaskState) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for TaskState

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TaskState

Source§

impl TryFrom<TaskState> for TaskState

Source§

type Error = ConvertError

The type returned in the event of a conversion error.
Source§

fn try_from( value: TaskState, ) -> Result<TaskState, <TaskState as TryFrom<TaskState>>::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more