ReAct Pattern
Theory
ReAct (Yao et al., 2023) is the standard pattern for LLM agents. Each iteration has three steps:
| Step | Content | Purpose |
|---|---|---|
| Thought | Model's reasoning in plain text | Selects tool + arguments; handles prior errors |
| Action | One tool call | Retrieves or computes real data |
| Observation | Tool's return value | Grounds the next Thought |
Taskuser query
Thoughtreason
Actiontool call
Observationresult
Answer?done or loop
Why it beats alternatives:
- vs. plain CoT — CoT reasons without external data, so multi-hop factual tasks hallucinate. ReAct Observations are ground truth.
- vs. blind tool chains — no reasoning between calls means wrong tools get called when earlier steps return unexpected results. Thought handles recovery.
Stopping conditions: final answer produced, or max_steps reached. A hard cap is non-negotiable — an agent looping on a broken tool will exhaust the context window.
Common implementations: LangChain create_react_agent, manual JSON loop with instruction-following models (GPT-4o, Claude 3.5+).