A unit of work managed by an agent runtime.
Tasks track lifecycle state, message history, and produced artifacts.
Summary
Functions
Creates a new task in the :submitted state.
Strips the internal :stream key from task metadata.
Returns true if the task is in a terminal state.
Truncates the task history to the last n entries.
Types
@type state() :: A2A.Task.Status.state()
@type t() :: %A2A.Task{ artifacts: [A2A.Artifact.t()], context_id: String.t() | nil, history: [A2A.Message.t()], id: String.t(), metadata: map(), status: A2A.Task.Status.t() }
Functions
Creates a new task in the :submitted state.
Strips the internal :stream key from task metadata.
The :stream key holds a raw enumerable/function ref used by the SSE
path and must be removed before JSON encoding.
Returns true if the task is in a terminal state.
@spec truncate_history(t(), non_neg_integer() | nil) :: t()
Truncates the task history to the last n entries.
Returns the task unchanged when n is nil. A value of 0 clears
the history entirely.