a2a_protocol_types/generated/task.rs
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Tom F. <[email protected]> (https://github.com/tomtom215)
3// @generated by tools/a2a-codegen from proto/a2a_v1/a2a.proto,
4// sha256 e195bf96ab630c69797851970203e1b2b6b19528f2e9803b7d904b91a5104016.
5// Included by the `task` module. Do not edit: change the proto or
6// crates/a2a-protocol-types/codegen.toml and regenerate (ADR 0016).
7
8/// Defines the possible lifecycle states of a `Task`.
9///
10/// On the wire each state is its `ProtoJSON` name (`"TASK_STATE_COMPLETED"`,
11/// spec ยง5.5); the v0.3 lowercase and kebab-case spellings are accepted on
12/// input.
13///
14/// This enum is closed to the v1.0 states. A future protocol revision that adds
15/// a state would be a wire-breaking change for the gRPC binding: an unknown
16/// `TASK_STATE_*` number from a newer peer is rejected by the protobuf
17/// conversion layer (with a field-scoped error) rather than silently discarded,
18/// so no task is ever reported in a bogus state.
19#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
20#[non_exhaustive]
21pub enum TaskState {
22 /// The task is in an unknown or indeterminate state.
23 #[serde(rename = "TASK_STATE_UNSPECIFIED", alias = "unspecified")]
24 Unspecified = 0,
25 /// Indicates that a task has been successfully submitted and acknowledged.
26 #[serde(rename = "TASK_STATE_SUBMITTED", alias = "submitted")]
27 Submitted = 1,
28 /// Indicates that a task is actively being processed by the agent.
29 #[serde(rename = "TASK_STATE_WORKING", alias = "working")]
30 Working = 2,
31 /// Indicates that a task has finished successfully. This is a terminal state.
32 #[serde(rename = "TASK_STATE_COMPLETED", alias = "completed")]
33 Completed = 3,
34 /// Indicates that a task has finished with an error. This is a terminal state.
35 #[serde(rename = "TASK_STATE_FAILED", alias = "failed")]
36 Failed = 4,
37 /// Indicates that a task was canceled before completion. This is a terminal state.
38 #[serde(rename = "TASK_STATE_CANCELED", alias = "canceled")]
39 Canceled = 5,
40 /// Indicates that the agent requires additional user input to proceed. This is an interrupted state.
41 #[serde(rename = "TASK_STATE_INPUT_REQUIRED", alias = "input-required")]
42 InputRequired = 6,
43 /// Indicates that the agent has decided to not perform the task.
44 /// This may be done during initial task creation or later once an agent
45 /// has determined it can't or won't proceed. This is a terminal state.
46 #[serde(rename = "TASK_STATE_REJECTED", alias = "rejected")]
47 Rejected = 7,
48 /// Indicates that authentication is required to proceed. This is an interrupted state.
49 #[serde(rename = "TASK_STATE_AUTH_REQUIRED", alias = "auth-required")]
50 AuthRequired = 8,
51}
52
53/// `Task` is the core unit of action for A2A.
54///
55/// It has a current status
56/// and when results are created for the task they are stored in the
57/// artifact. If there are multiple turns for a task, these are stored in
58/// history.
59///
60/// The wire `kind` field (`"task"`) is injected by enclosing discriminated
61/// unions such as [`crate::events::StreamResponse`] and
62/// [`crate::responses::SendMessageResponse`]. Standalone `Task` values received
63/// over the wire may include `kind`; serde silently tolerates unknown fields, so
64/// no action is needed on the receiving side.
65#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
66#[serde(rename_all = "camelCase")]
67#[non_exhaustive]
68pub struct Task {
69 /// Unique identifier (e.g. UUID) for the task, generated by the server for a
70 /// new task.
71 pub id: crate::task::TaskId,
72 /// Unique identifier (e.g. UUID) for the contextual collection of interactions
73 /// (tasks and messages).
74 ///
75 /// The proto leaves `context_id` optional, and `ProtoJSON` printers omit an
76 /// empty string, so a peer's task may arrive without the key; it parses
77 /// as an empty id rather than failing the whole response.
78 #[serde(alias = "context_id", default = "crate::task::empty_context_id")]
79 pub context_id: crate::task::ContextId,
80 /// The current status of a `Task`, including `state` and a `message`.
81 pub status: crate::task::TaskStatus,
82 /// A set of output artifacts for a `Task`.
83 #[serde(skip_serializing_if = "Option::is_none")]
84 pub artifacts: Option<Vec<crate::artifact::Artifact>>,
85 /// The history of interactions from a `Task`.
86 #[serde(skip_serializing_if = "Option::is_none")]
87 pub history: Option<Vec<crate::message::Message>>,
88 /// A key/value object to store custom metadata about a task.
89 #[serde(skip_serializing_if = "Option::is_none")]
90 pub metadata: Option<serde_json::Value>,
91}
92
93/// A container for the status of a task
94#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
95#[serde(rename_all = "camelCase")]
96#[non_exhaustive]
97pub struct TaskStatus {
98 /// The current state of this task.
99 pub state: crate::task::TaskState,
100 /// A message associated with the status.
101 #[serde(skip_serializing_if = "Option::is_none")]
102 pub message: Option<crate::message::Message>,
103 /// ISO 8601 Timestamp when the status was recorded.
104 /// Example: "2023-10-27T10:00:00Z"
105 #[serde(skip_serializing_if = "Option::is_none")]
106 pub timestamp: Option<String>,
107}