# `A2A.Task`
[🔗](https://github.com/actioncard/a2a-elixir/blob/main/lib/a2a/task.ex#L1)

A unit of work managed by an agent runtime.

Tasks track lifecycle state, message history, and produced artifacts.

# `state`

```elixir
@type state() :: A2A.Task.Status.state()
```

# `t`

```elixir
@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()
}
```

# `new`

```elixir
@spec new(keyword()) :: t()
```

Creates a new task in the `:submitted` state.

# `strip_stream_metadata`

```elixir
@spec strip_stream_metadata(t()) :: t()
```

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.

# `terminal?`

```elixir
@spec terminal?(t()) :: boolean()
```

Returns `true` if the task is in a terminal state.

# `truncate_history`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
