Planning & Control Flow

ReAct

Interleave a single thought, a single tool call, and a single observation per step so the agent reasons over fresh evidence.

Problem

Pure chain-of-thought reasoning produces fluent, confident answers that hallucinate the facts a tool would have returned. Pure tool-blasting — calling several tools speculatively per turn — wastes calls on the wrong things, returns more results than the model can use, and gives the agent no chance to think between calls. Without a structured interleave of reasoning and action, the agent either guesses or thrashes, and the loop has no clean place to put a step budget or a termination check.

Solution

On each step the agent emits Thought (private reasoning), Action (one tool call), Observation (the tool's result). Repeat until the agent decides to answer. A step budget bounds the loop.

When to use

  • The next action depends on what was learned from the previous action.
  • The agent needs tool access during a multi-step task.
  • Outputs from tools are short and inspectable so the model can react to them.

Open the full interactive page

Diagram, neighbourhood map, code examples, related patterns and full provenance.

Related