Jido.AI.Reasoning.ReAct.State (Jido AI v2.1.0)

View Source

Runtime state for a single ReAct run.

Summary

Functions

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

Clears all pending tool calls.

Returns elapsed runtime in milliseconds.

Restores state from a minimal checkpoint map.

Increments the reasoning iteration counter.

Merges usage counters into existing state usage map.

Returns the minimal serializable map required to resume execution.

Creates initial runtime state for a new query.

Stores terminal error value.

Stores the current LLM call id.

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

Replaces pending tool calls.

Stores terminal result value.

Sets runtime status.

Returns the Zoi schema used to validate ReAct runtime state.

Types

t()

@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(),
  pending_tool_calls: [
    %Jido.AI.Reasoning.ReAct.PendingToolCall{
      arguments: map(),
      attempts: integer(),
      duration_ms: nil | integer(),
      id: binary(),
      name: binary(),
      result: nil | any(),
      status: atom()
    }
  ],
  request_id: binary(),
  result: nil | nil | any(),
  run_id: binary(),
  seq: integer(),
  started_at_ms: integer(),
  status: atom(),
  updated_at_ms: integer(),
  usage: map(),
  version: integer()
}

Functions

bump_seq(state)

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

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

clear_pending_tools(state)

@spec clear_pending_tools(t()) :: t()

Clears all pending tool calls.

duration_ms(state)

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

Returns elapsed runtime in milliseconds.

from_checkpoint_map(map)

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

Restores state from a minimal checkpoint map.

inc_iteration(state)

@spec inc_iteration(t()) :: t()

Increments the reasoning iteration counter.

merge_usage(state, usage)

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

Merges usage counters into existing state usage map.

minimal_checkpoint_map(state)

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

Returns the minimal serializable map required to resume execution.

new(query, system_prompt, opts \\ [])

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

Creates initial runtime state for a new query.

put_error(state, error)

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

Stores terminal error value.

put_llm_call_id(state, call_id)

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

Stores the current LLM call id.

put_llm_response_id(state, response_id)

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

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

put_pending_tools(state, pending)

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

Replaces pending tool calls.

put_result(state, result)

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

Stores terminal result value.

put_status(state, status)

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

Sets runtime status.

schema()

@spec schema() :: term()

Returns the Zoi schema used to validate ReAct runtime state.