Why it matters

ReAct is the foundation of most modern agent frameworks. Understanding it explains why agents behave certain ways and how to design agent prompts.

Advertisement

The architecture

Loop: Thought (reason about current state) → Action (call a tool with arguments) → Observation (result of tool) → repeat. Continues until final answer.

Prompt shows examples of this loop; agent learns to produce structured Thought/Action/Observation trace.

ReAct step cycleThoughtreason next stepActioncall toolObservationtool resultLoop repeats until agent produces final answer; each cycle is one reasoning + tool call
ReAct iteration.
Advertisement

How it works end to end

Structured output: parse Thought/Action/Observation format explicitly. Tool call is a named function + arguments.

Termination: agent decides when to stop (produce final answer) vs continue. Cap max iterations to prevent runaway.

Error handling: when tool errors, agent gets error as observation. Can retry with different args or give up.