# `Jido.AI.Reasoning.ReAct.State`
[🔗](https://github.com/agentjido/jido_ai/blob/v2.4.0/lib/jido_ai/reasoning/react/state.ex#L1)

Runtime state for a single ReAct run.

# `t`

```elixir
@type t() :: %Jido.AI.Reasoning.ReAct.State{
  active_tools: map(),
  context: any(),
  error: nil | nil | any(),
  iteration: integer(),
  llm_call_id: nil | nil | binary(),
  llm_response_id: nil | nil | binary(),
  output: map(),
  pending_tool_calls: [
    %Jido.AI.Reasoning.ReAct.PendingToolCall{
      action_module: nil | atom(),
      arguments: map(),
      attempts: integer(),
      duration_ms: nil | integer(),
      id: binary(),
      name: binary(),
      result: nil | any(),
      status: atom()
    }
  ],
  prev_tool_signature: nil | nil | any(),
  request_id: binary(),
  result: nil | nil | any(),
  run_id: binary(),
  seq: integer(),
  started_at_ms: integer(),
  status: atom(),
  streaming_text: binary(),
  streaming_thinking: binary(),
  updated_at_ms: integer(),
  usage: map(),
  version: integer()
}
```

# `adopt_seq`

```elixir
@spec adopt_seq(t(), integer() | nil) :: t()
```

Advances the event sequence counter to `seq` when it is ahead of the current
value, leaving it untouched otherwise.

Used to reconcile sequence numbers allocated out-of-band by the tool-execution
heartbeat (which runs in a separate process while the runner is blocked inside
`Task.async_stream`). Adopting the heartbeat's final seq guarantees the next
normal event the runner emits is strictly greater than every keepalive,
preserving the monotonic-and-unique seq invariant.

# `bump_seq`

```elixir
@spec bump_seq(t()) :: {t(), pos_integer()}
```

Increments the event sequence counter and returns `{state, next_seq}`.

# `clear_pending_tools`

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

Clears all pending tool calls.

# `clear_streaming`

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

Clears streaming accumulators before a new LLM turn starts.

# `duration_ms`

```elixir
@spec duration_ms(t()) :: non_neg_integer()
```

Returns elapsed runtime in milliseconds.

# `from_checkpoint_map`

```elixir
@spec from_checkpoint_map(map()) :: {:ok, t()} | {:error, term()}
```

Restores state from a minimal checkpoint map.

# `inc_iteration`

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

Increments the reasoning iteration counter.

# `merge_usage`

```elixir
@spec merge_usage(t(), map() | nil) :: t()
```

Merges usage counters into existing state usage map.

# `minimal_checkpoint_map`

```elixir
@spec minimal_checkpoint_map(t()) :: map()
```

Returns the minimal serializable map required to resume execution.

# `new`

```elixir
@spec new(String.t(), String.t() | nil, keyword()) :: t()
```

Creates initial runtime state for a new query.

# `put_error`

```elixir
@spec put_error(t(), term()) :: t()
```

Stores terminal error value.

# `put_llm_call_id`

```elixir
@spec put_llm_call_id(t(), String.t() | nil) :: t()
```

Stores the current LLM call id.

# `put_llm_response_id`

```elixir
@spec put_llm_response_id(t(), String.t() | nil) :: t()
```

Stores the latest provider response id for multi-turn continuation.

# `put_output`

```elixir
@spec put_output(t(), map()) :: t()
```

Stores structured output metadata.

# `put_pending_tools`

```elixir
@spec put_pending_tools(t(), [Jido.AI.Reasoning.ReAct.PendingToolCall.t()]) :: t()
```

Replaces pending tool calls.

# `put_result`

```elixir
@spec put_result(t(), term()) :: t()
```

Stores terminal result value.

# `put_status`

```elixir
@spec put_status(t(), atom()) :: t()
```

Sets runtime status.

# `schema`

```elixir
@spec schema() :: term()
```

Returns the Zoi schema used to validate ReAct runtime state.

---

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