ReAct (Reasoning + Acting) is the foundational agent loop. The model alternates between THOUGHT (chain-of-thought reasoning) and ACTION (tool call). After observing the action's result, it loops. Most production agents are variants of this pattern.

Advertisement

The loop

Thought: I need to know today's weather in Bangalore.
Action: weather(location='Bangalore')
Observation: 28C, light rain
Thought: User asked if they need an umbrella. Light rain → yes.
Answer: Yes, carry an umbrella — it's lightly raining at 28C.

Why it works

Externalizing reasoning into THOUGHT steps lets the model reason about whether to act, which action, and how to interpret results. Without ReAct, models tend to either hallucinate answers or make every action a guess.

Advertisement

Failure modes

Infinite loops: model keeps choosing the same wrong action. Cap max iterations (e.g., 8). Premature answers: model jumps to ANSWER without enough Observations. Add system instruction enforcing minimum tool calls for non-trivial queries. Tool selection: with 20+ tools, model picks wrong one. Use tool retrieval (embed tool descriptions, retrieve top-5 per query).

Frameworks

LangChain agents, LlamaIndex agents, Anthropic computer-use, OpenAI Assistants API — all implement ReAct-like loops with varying degrees of customization. For complex production agents, building your own loop is often clearer than using a framework.

When to use Plan-and-Execute instead

Long-horizon tasks (10+ tool calls) benefit from upfront planning. Plan-and-Execute: first generate full plan, then execute step-by-step. Slower start, more reliable for complex workflows. ReAct better for short Q+A; Plan-and-Execute better for multi-step research.

ReAct for short tool-using tasks. Cap iterations, enforce thought-before-action, use tool retrieval if N tools > 10.