Overview
TheReactEngine implements the canonical Reason + Act (ReAct) pattern for agent reasoning. It executes a simple loop where the model thinks, optionally calls tools, processes results, and repeats until a final answer is reached.
This is the default reasoning engine when no strategy is configured.
Paper: “ReAct: Synergizing Reasoning and Acting in Language Models” (Yao et al., 2022)
When to Use
UseReactEngine when:
- You need a straightforward, reliable reasoning loop
- Your task involves iterative tool use (search, calculate, API calls)
- You want the model to decide when it has gathered enough information
- You don’t need explicit planning or reflection
Constructor
Configuration
Maximum number of reasoning steps before forcing a final answer. Each step includes a model call and optional tool execution.
Usage Example
How It Works
- Think: Model receives messages and generates a response (with optional tool calls)
- Act: If tool calls are present, execute them and append results to conversation
- Repeat: Loop back to step 1 with updated context
- Terminate: When no tool calls are made, return the model’s final response
Step Emissions
- ThoughtStep: Emitted when the model generates content alongside tool calls
- ResponseStep: Emitted when the final answer is produced
Error Handling
Throws an error ifmaxSteps is reached without the model producing a final answer:
String Alias
You can use the string alias'react' instead of instantiating the class:
Implementation Reference
Source:packages/reasoning/src/engines/react.ts:31