Jido.AI.Reasoning.ReAct.Strategy (Jido AI v2.2.0)

Copy Markdown View Source

ReAct strategy delegated to an internal per-parent worker agent.

The parent strategy remains the public orchestration boundary (ask/await/ask_sync), while runtime execution is delegated to a lazily spawned child worker tagged :react_worker.

Delegation Model

  1. Parent receives "ai.react.query" and prepares runtime config/context.
  2. Parent lazily spawns internal worker on first request (if needed).
  3. Parent emits "ai.react.worker.start" to worker.
  4. Worker streams Jido.AI.Reasoning.ReAct events and emits "ai.react.worker.event" to parent.
  5. Parent applies runtime events to parent state and emits external lifecycle/LLM/tool signals.

Worker Lifecycle

  • Child tag is fixed as :react_worker.
  • Single active run is enforced (:reject busy policy).
  • Worker crash during active request marks the request failed.
  • No machine-driven fallback path is retained.

Trace Retention

Parent stores per-request runtime event history in request_traces with a hard cap:

%{request_id => %{events: [event, ...], truncated?: boolean()}}

Once 2000 events are stored for a request, truncated? is set to true and new events are not appended.

Summary

Functions

Returns the action atom for request cancellation.

Returns the canonical action atom for context lifecycle operations.

Returns the action atom for injecting user-style input into an active ReAct request.

Returns the list of currently registered tools for the given agent.

Returns the legacy action atom for handling streaming deltas (no-op in delegated mode).

Returns the legacy action atom for handling LLM results (no-op in delegated mode).

Returns the action atom for registering a tool dynamically.

Returns the action atom for handling request rejections.

Returns the legacy action atom for direct runtime stream events (no-op in delegated mode).

Returns the action atom for updating the base system prompt.

Returns the action atom for updating tool context.

Returns the action atom for starting a ReAct conversation.

Returns the action atom for steering an active ReAct request.

Returns the legacy action atom for handling tool results (no-op in delegated mode).

Returns the action atom for unregistering a tool.

Types

config()

@type config() :: %{
  tools: [module()],
  reqllm_tools: [ReqLLM.Tool.t()],
  actions_by_name: %{required(String.t()) => module()},
  request_transformer: module() | nil,
  system_prompt: String.t(),
  model: String.t(),
  max_iterations: pos_integer(),
  max_tokens: pos_integer(),
  streaming: boolean(),
  base_tool_context: map(),
  base_req_http_options: list(),
  base_llm_opts: keyword(),
  provider_opt_keys_by_string: %{optional(String.t()) => atom()},
  request_policy: :reject,
  stream_timeout_ms: non_neg_integer(),
  stream_receive_timeout_ms: pos_integer(),
  stream_timeout_ms: non_neg_integer(),
  stream_receive_timeout_ms: pos_integer(),
  tool_timeout_ms: pos_integer(),
  tool_max_retries: non_neg_integer(),
  tool_retry_backoff_ms: non_neg_integer(),
  effect_policy: map(),
  output: Jido.AI.Output.t() | nil,
  observability: map(),
  runtime_adapter: true,
  runtime_task_supervisor: pid() | atom() | nil,
  agent_id: String.t() | nil
}

Functions

cancel_action()

@spec cancel_action() :: :ai_react_cancel

Returns the action atom for request cancellation.

context_modify_action()

@spec context_modify_action() :: :ai_react_context_modify

Returns the canonical action atom for context lifecycle operations.

inject_action()

@spec inject_action() :: :ai_react_inject

Returns the action atom for injecting user-style input into an active ReAct request.

list_tools(agent)

@spec list_tools(Jido.Agent.t()) :: [module()]

Returns the list of currently registered tools for the given agent.

llm_partial_action()

@spec llm_partial_action() :: :ai_react_llm_partial

Returns the legacy action atom for handling streaming deltas (no-op in delegated mode).

llm_result_action()

@spec llm_result_action() :: :ai_react_llm_result

Returns the legacy action atom for handling LLM results (no-op in delegated mode).

register_tool_action()

@spec register_tool_action() :: :ai_react_register_tool

Returns the action atom for registering a tool dynamically.

request_error_action()

@spec request_error_action() :: :ai_react_request_error

Returns the action atom for handling request rejections.

runtime_event_action()

@spec runtime_event_action() :: :ai_react_runtime_event

Returns the legacy action atom for direct runtime stream events (no-op in delegated mode).

set_system_prompt_action()

@spec set_system_prompt_action() :: :ai_react_set_system_prompt

Returns the action atom for updating the base system prompt.

set_tool_context_action()

@spec set_tool_context_action() :: :ai_react_set_tool_context

Returns the action atom for updating tool context.

start_action()

@spec start_action() :: :ai_react_start

Returns the action atom for starting a ReAct conversation.

steer_action()

@spec steer_action() :: :ai_react_steer

Returns the action atom for steering an active ReAct request.

tool_result_action()

@spec tool_result_action() :: :ai_react_tool_result

Returns the legacy action atom for handling tool results (no-op in delegated mode).

unregister_tool_action()

@spec unregister_tool_action() :: :ai_react_unregister_tool

Returns the action atom for unregistering a tool.