GenAI Systems Lab Open interactive version →
Agents & Tool Use 8 min read

The ReAct Pattern: How LLM Agents Reason and Act

Thought → Action → Observation loops explained. How ReAct enables tool use, where it breaks, and how to trace what your agent actually did.

**Prerequisite: any earlier step — you just need to know what an LLM is.** After this post you'll understand the ReAct pattern — how reasoning steps and tool calls interleave — and why it's the foundation of every tool-using agent you'll build.

Before ReAct, LLM agents were brittle. You'd give the model tools and hope it called them correctly. The model had no way to express what it was trying to do before doing it, making debugging and course-correction impossible.

ReAct (Reasoning + Acting) changed this by interleaving explicit thought steps with action steps. The model now writes what it's thinking before it calls a tool — and that thought is visible, traceable, and correctable.

The ReAct loop

Thought: I need to find the capital of France first.
Action: search("capital of France")
Observation: Paris is the capital of France.

Thought: Now I need the population of Paris.
Action: search("population of Paris 2024")
Observation: Paris has a population of approximately 2.1 million in the city proper.

Thought: I have the answer.
Final Answer: The capital of France is Paris, with a population of ~2.1 million.

Each Thought-Action-Observation triplet is one step. The loop continues until the model produces a Final Answer. The model sees its own previous steps in context, allowing it to correct mistakes and build on intermediate results.

Why the Thought step matters

Implementing ReAct in 2025

You don't need to prompt-engineer the thought-action loop manually anymore. LangChain's AgentExecutor, LangGraph, and OpenAI's function calling all implement ReAct-style loops natively. The model is fine-tuned to produce structured tool calls rather than freeform text.

Modern tool-calling APIs (OpenAI, Anthropic, Gemini) encode the ReAct pattern at the model level. The model outputs a JSON tool call object instead of freeform text, which is more reliable and parseable. The thought step lives in the model's reasoning, not the output.

Where ReAct breaks

Always set a max_steps limit. An uncapped ReAct loop will happily call tools 50 times and burn through your budget before timing out. 10–15 steps covers 95% of real-world agent tasks.

Step through a ReAct trace →: Run the Agent Loop Simulator and watch Thought-Action-Observation unfold step by step.

Try it interactively

GenAI Systems Lab is a free platform for AI engineers — configure real failure modes, break things, and build the judgment that gets you hired.

Open GenAI Systems Lab →