Skip to main content
AI & Agents

ReAct Pattern

The ReAct pattern — short for Reason + Act — is an agent control loop in which a language model alternates between producing a reasoning step and taking an action: it thinks, calls a tool, reads the observation, and thinks again until the task is complete. Introduced by Yao et al. in 2022, it remains the default loop behind most tool-using agents.

A ReAct run produces an interleaved trace: Thought ("I need the order before I can check the policy"), Action (lookup_order), Observation (the order record), Thought ("the order is within the return window"), and so on. The structure looks simple, but each observation grounds the next reasoning step in something real, which is precisely what a pure reasoning chain lacks.

Interleaving beats plan-then-execute for open-ended tasks. A plan written up front commits to steps before any facts are known and fails silently when reality diverges. ReAct re-plans after every observation, so a missing record, an empty search or an unexpected error becomes new information rather than a broken plan. The trade-off is latency and cost — every step is a model call — which is why deterministic sub-sequences are lifted out of the loop into ordinary code wherever possible.

Modern frameworks implement the same loop with better plumbing. LangGraph ships a prebuilt ReAct agent as a stateful graph with checkpoints; the OpenAI Agents SDK runs an equivalent loop with handoffs, guardrails and tracing around it. The characteristic production failures are loops that never terminate and reasoning that drifts from the goal, and both are handled the same way: iteration and spend caps enforced in code, typed tools with unambiguous results, and stop conditions checked outside the model.

A concrete run shows why the pattern earns its cost. Asked to refund the order mentioned in an angry email, the agent reasons that it needs the order first, calls lookup_order with the sender's address, reads the record, reasons that the purchase falls inside the returns window, calls check_policy to confirm, then issues the refund and drafts the reply. Each step depends on facts only the previous action could supply, so no plan written in advance could have contained them. That dependence on unknown intermediate facts is the dividing line between tasks that need the loop and tasks that need a script.

Where teams go wrong is leaving deterministic work inside the loop. If steps two through five always run in the same order whenever step one succeeds, that sequence is code rather than reasoning, and routing it through a model adds cost, latency and a chance of deviation for no benefit. The mature form of most production agents is a ReAct loop wrapped around a small number of genuine decision points, with everything between those points compiled down to ordinary functions that run exactly the same way every time.

Codazz builds this in production — AI Agent Development.

FAQ

ReAct Pattern
FAQ.

Common questions about react pattern.

Ask Us Anything

Chain of thought is reasoning without actions: the model works through steps and produces an answer. ReAct interleaves reasoning with real tool calls, so each reasoning step can react to actual observations from the world. Chain of thought improves how a model thinks; ReAct lets it act on what it finds.

Yes, because it describes the control loop rather than the reasoning style. Whether the model writes explicit Thought lines or reasons internally, a tool-using agent still alternates between deciding and acting, and still needs iteration limits, typed tools and termination conditions around that loop. The pattern outlived the prompt format that introduced it.

Enough for the task class, and a hard stop beyond that. Simple lookup-and-answer tasks rarely need more than three or four steps; research agents may legitimately need fifteen. Set the cap from measured runs rather than intuition, enforce it in code, and treat hitting the cap as a failure worth alerting on — a loop that terminates at the limit every time is telling you the task, the tools or the prompt is wrong.