Skip to main content

react_agent

react_agent(...) builds a ReAct loop as a Step. Key parameters:
  • planner: an LLM step created with llm_step(...)
  • tools: mapping from names to tool steps created with tool_step(...)
  • max_steps / policy.max_iterations: maximum iterations
  • Key overrides for where data is stored in state (llm_response_key, tool_result_key, etc.)

State keys and defaults

Default keys:
  • llm_response: LLMResponse returned by the planner
  • tool_name: name of the tool to run
  • tool_args: dict of tool arguments
  • tool_result: tool output
  • tool_call_id: tool call identifier (if present)
  • final: final assistant text (stop condition)

Tool validation and dispatch

Validation rules:
  • Every entry in tools must be a Step
  • Each tool step must have annotations["kind"] == "tool"
  • Tool step names must be unique
Dispatch rules:
  • ReAct executes only the first tool call in LLMResponse.tool_calls per iteration
  • If the tool name cannot be resolved, a KeyError is raised
  • If the tool does not set the configured result key, an error is raised

Next steps