ReAct — short for Reason + Act — is the load-bearing loop behind most production agents: interleave a written thought, a tool call, and an observation, then repeat until the goal is provably met.
Introduced by Yao et al. (2022), the pattern's core insight is that reasoning and acting are mutually reinforcing. A written thought decomposes the goal and reasons about what is missing; an action grounds that reasoning in the real world via a tool; an observation feeds unfiltered reality back into the context. Models running this loop hallucinate dramatically less than the same models asked to answer in one shot, because every factual claim can be pinned to an observation rather than to a parameter.
The loop is also a debugging interface. Because each step is labelled, a failed run reads as a story — "the model assumed the file existed, the tool disagreed, the model never recovered" — instead of a single inscrutable completion. That legibility is why virtually every agent framework traces its execution in ReAct-shaped steps even when the internals are more exotic.
Making Loops Terminate
The engineering is in the exits. A production ReAct loop needs explicit closure conditions:
- Step budget: a hard cap on iterations, tuned per task class — ReAct papers found 6–12 steps sufficient for search QA, while coding tasks routinely need dozens.
- Stop conditions: a structured
finish(answer)action so the model exits by decision, not by falling off a cliff. - Loop detection: hash recent (action, args) pairs; repeating the same failing call with identical inputs is a dead strategy and should force a replan.
- Stall detection: if observations stop changing the thought trajectory, the context is saturated — compact or restart with a different plan.
The pattern's honest limitation is drift: over long horizons, early observations fall out of the effective context and the model re-derives stale facts. That weakness is exactly what memory tiers, scratchpads, and plan-and-execute variants were invented to fix — which is why ReAct is best read as the assembly language of agents, not the whole architecture.