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

View Source

Public API for Task-based ReAct runtime.

This module provides streaming and checkpoint-aware execution that can be reused by actions and strategies.

Summary

Functions

Normalizes user-provided configuration into a Config struct.

Marks a checkpoint token as cancelled and returns a replacement token.

Collects run output from an event stream or checkpoint token.

Reduces a ReAct event stream into terminal result, usage, token, and full trace.

Resumes a run from a checkpoint token and returns run metadata plus a stream handle.

Injects user-visible input into an active ReAct-backed agent.

Runs ReAct to completion and returns an aggregated result map.

Starts a run and returns run metadata plus a stream handle.

Steers an active ReAct-backed agent with additional user-visible input.

Starts a new ReAct run and returns a lazy event stream.

Resumes a ReAct run from state and returns a lazy event stream.

Types

config_input()

@type config_input() :: Jido.AI.Reasoning.ReAct.Config.t() | map() | keyword()

Functions

build_config(config)

@spec build_config(config_input()) :: Jido.AI.Reasoning.ReAct.Config.t()

Normalizes user-provided configuration into a Config struct.

cancel(checkpoint_token, config, reason \\ :cancelled)

@spec cancel(String.t(), config_input(), atom()) ::
  {:ok, String.t()} | {:error, term()}

Marks a checkpoint token as cancelled and returns a replacement token.

collect(checkpoint_token, config, opts)

@spec collect(Enumerable.t() | String.t(), config_input(), keyword()) ::
  {:ok, map()} | {:error, term()}

Collects run output from an event stream or checkpoint token.

collect_stream(events)

@spec collect_stream(Enumerable.t()) :: map()

Reduces a ReAct event stream into terminal result, usage, token, and full trace.

continue(checkpoint_token, config, opts \\ [])

@spec continue(String.t(), config_input(), keyword()) ::
  {:ok, map()} | {:error, term()}

Resumes a run from a checkpoint token and returns run metadata plus a stream handle.

inject(agent_server, content, opts \\ [])

@spec inject(GenServer.server(), String.t(), keyword()) ::
  {:ok, Jido.Agent.t()} | {:error, term()}

Injects user-visible input into an active ReAct-backed agent.

This is intended for programmatic or inter-agent steering and follows the same queuing rules as steer/3.

run(query, config, opts \\ [])

@spec run(String.t(), config_input(), keyword()) :: map()

Runs ReAct to completion and returns an aggregated result map.

start(query, config, opts \\ [])

@spec start(String.t(), config_input(), keyword()) :: {:ok, map()} | {:error, term()}

Starts a run and returns run metadata plus a stream handle.

steer(agent_server, content, opts \\ [])

@spec steer(GenServer.server(), String.t(), keyword()) ::
  {:ok, Jido.Agent.t()} | {:error, term()}

Steers an active ReAct-backed agent with additional user-visible input.

Returns {:ok, agent} when the input is queued for the current run or {:error, {:rejected, reason}} when no eligible run is active.

Queued input is best-effort. If the run terminates before the runtime drains the queue into conversation state, the queued input is dropped.

stream(query, config, opts \\ [])

@spec stream(String.t(), config_input(), keyword()) :: Enumerable.t()

Starts a new ReAct run and returns a lazy event stream.

stream_from_state(state, config, opts \\ [])

@spec stream_from_state(Jido.AI.Reasoning.ReAct.State.t(), config_input(), keyword()) ::
  Enumerable.t()

Resumes a ReAct run from state and returns a lazy event stream.