Quick Answer: The ReAct pattern is a Thought → Action → Observation loop that lets AI agents reason step-by-step while using real tools — the most widely deployed agent architecture in production today.
If you've ever watched a Claude or GPT-4 agent "think out loud" — "I need to search for this, then calculate that, then verify the result" — you've seen the ReAct pattern in action. It's the invisible engine behind most AI agents in 2026, from customer support bots to autonomous coding assistants.
The ReAct pattern (short for Reason + Act) was introduced by Shunyu Yao et al. at ICLR 2023 and immediately became the default architecture in LangChain. Three years later, it's still the mental model every agent developer needs to understand — even as native function calling has replaced hand-parsed text traces in most production systems.
This guide covers how ReAct works from first principles, why it outperforms pure Chain-of-Thought reasoning, how it fails in the wild, and how to implement it today using LangGraph.
What Is the ReAct Pattern?
ReAct solves a fundamental problem: language models know a lot, but their knowledge is frozen at training time and they can't take real-world actions.
Chain-of-Thought prompting helped models reason better by thinking step-by-step before answering. But the thoughts were still just... thoughts. No web search. No database query. No API call.
ReAct adds a second track to the reasoning loop: external actions. The model doesn't just think — it acts, receives feedback, and incorporates that feedback into its next thought.
The original paper tested ReAct on multi-hop question answering (HotPotQA), fact verification (FEVER), interactive decision-making (ALFWorld), and web shopping (WebShop). The results were striking:
- ALFWorld: +34 percentage points over prior imitation/RL baselines
- WebShop: +10 percentage points absolute improvement
- HotPotQA: 35.1% exact match using a ReAct + CoT hybrid, vs. 28.7% for standard prompting
The key insight: grounding reasoning in real observations dramatically reduces hallucination.
The Thought → Action → Observation Loop
Every ReAct agent operates on the same three-step cycle:
- Thought — the model reasons about what to do next, in natural language
- Action — the model calls a tool (search, calculator, database, API)
- Observation — the result of the action is appended to the context
The loop repeats until the model emits a Final Answer.
Here's what a real ReAct trajectory looks like for the question "What is the current price of the most expensive item in the Amazon top 10 electronics list?":
Thought: I need to find the current Amazon top 10 electronics list.
Action: search["Amazon top 10 electronics 2026"]
Observation: [search result: list of 10 products with prices]
Thought: The most expensive item is the Sony Bravia XR-85 at $4,299.
Action: search["Sony Bravia XR-85 current price"]
Observation: [search result: $3,999 (sale price today)]
Thought: The current price is $3,999, lower than the list price.
Final Answer: The most expensive item is the Sony Bravia XR-85, currently priced at $3,999.
Each observation becomes part of the context. The model's next thought is informed by real data, not parametric memory.
Every step is appended to the same context window. By step 5, the model sees the complete history of its own reasoning and all tool results. This is both ReAct's strength (coherent multi-step reasoning) and its main scaling challenge (long tasks overflow the context window).
ReAct vs. Chain-of-Thought: What's the Difference?
Chain-of-Thought prompting was a breakthrough — asking models to reason step-by-step before answering improved accuracy dramatically on complex problems. But CoT has a hard ceiling: it can only reason about what the model already knows.
| Dimension | Chain-of-Thought | ReAct |
|---|---|---|
| External tools | No | Yes (search, API, DB, code) |
| Hallucination risk | High on factual questions | Lower — grounded in observations |
| Token cost | Low | Higher (full trajectory in context) |
| Best for | Math, logic, structured reasoning | Factual lookup, web tasks, CRUD operations |
| Adaptability | Fixed reasoning chain | Can adapt based on what tools return |
| Context growth | Bounded | Grows with each step — can overflow |
The practical takeaway: use Chain-of-Thought when the answer lives in the model's weights (math, code generation, classification). Use ReAct when the answer requires external state (current prices, live data, file systems, databases).
In practice, the two combine well. The original ReAct paper's best results came from a hybrid: use CoT when the model is confident, switch to ReAct when it needs to verify facts. LangGraph makes this easy to implement with conditional routing.
ReAct vs. Other Agent Patterns
ReAct isn't the only pattern in the toolkit. Here's where it sits in the broader landscape — also covered in our deep-dive on AI agent reasoning patterns:
| Pattern | Core Idea | Token Cost | Best For |
|---|---|---|---|
| ReAct | Interleaved reasoning + tool use | Medium | Most general tasks |
| Plan-and-Execute | Plan all steps upfront, then execute | Low per step | Predictable, structured workflows |
| ReWOO | Parallelize all tool calls upfront | Very low | Token-sensitive, predictable tasks |
| Reflexion | ReAct + self-critique across episodes | High | Tasks needing iterative improvement |
| Tree of Thoughts | Explore multiple reasoning branches | Very high | Math, logic puzzles with clear eval |
ReAct's advantage is adaptability — it can change course based on what tools return. Plan-and-Execute is more efficient when the task is predictable; ReWOO removes the full trajectory from context entirely (much cheaper), but can't handle unexpected observations. Reflexion adds a cross-episode memory layer on top of ReAct — after failing, the agent writes a self-critique and tries again smarter.
If you're not sure which pattern to use, start with ReAct. It handles the broadest range of tasks with reasonable token efficiency. Optimize to Plan-and-Execute or ReWOO once you know your task structure well.
How to Implement the ReAct Pattern
Minimal Python Implementation (from Scratch)
The core of ReAct is just a loop — call the model, parse the action, run the tool, append the observation, repeat:
import re
from anthropic import Anthropic
client = Anthropic()
tools = {
"search": lambda q: web_search(q), # your search function
"calculate": lambda expr: eval(expr), # simple calculator
}
def react_agent(question: str, max_steps: int = 10) -> str:
messages = [{"role": "user", "content": question}]
system = """You are a ReAct agent. For each step, output:
Thought: <your reasoning>
Action: <tool_name>[<input>]
...or when done:
Final Answer: <your answer>"""
for _ in range(max_steps):
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
system=system,
messages=messages,
)
text = response.content[0].text
messages.append({"role": "assistant", "content": text})
# Check for final answer
if "Final Answer:" in text:
return text.split("Final Answer:")[-1].strip()
# Parse and execute action
match = re.search(r"Action: (\w+)\[(.+?)\]", text)
if match:
tool_name, tool_input = match.group(1), match.group(2)
observation = tools.get(tool_name, lambda x: "Tool not found")(tool_input)
messages.append({
"role": "user",
"content": f"Observation: {observation}"
})
return "Max steps reached without a final answer."
The max_steps guard is critical. Without it, a confused agent will loop forever.
Production Implementation with LangGraph
In production, use LangGraph's create_react_agent. It handles the loop, tool routing, state management, and streaming out of the box:
from langgraph.prebuilt import create_react_agent
from langchain_anthropic import ChatAnthropic
from langchain_community.tools.tavily_search import TavilySearchResults
model = ChatAnthropic(model="claude-sonnet-4-6")
tools = [TavilySearchResults(max_results=3)]
# Creates a full ReAct graph with tool nodes and routing
agent = create_react_agent(model, tools)
# Run the agent
result = agent.invoke({
"messages": [("user", "What are the top 3 AI agent frameworks in 2026?")]
})
print(result["messages"][-1].content)
LangGraph compiles this into a stateful graph: a model node, a tool execution node, and an edge that routes back to the model after each tool call until it sees no more tool calls in the response.
LangGraph's create_react_agent (introduced in LangGraph 1.0, October 2025) replaced the older LangChain AgentExecutor pattern. LangGraph is the production standard — it's more debuggable, supports streaming, and handles interrupts for human-in-the-loop flows. For new projects, always use LangGraph.
ReAct Failure Modes (and How to Fix Them)
ReAct is powerful but brittle in specific scenarios. Knowing the failure modes saves you from embarrassing production bugs.
1. Infinite Loops
Symptom: The agent calls the same tool repeatedly with similar inputs, never converging on an answer.
Cause: The tool returns an ambiguous result, and the agent keeps trying to resolve it.
Fix: Always set max_iterations (LangGraph default: 25). Add loop detection that checks if the last 3 actions are identical.
2. Context Window Overflow
Symptom: Error after 10–15 steps on long tasks.
Cause: Every step appends to the context. A 10-step trajectory with 500-token observations can easily hit 15K+ tokens.
Fix: Use a summarization step that compresses older observations. LangGraph supports this via custom MessagesState with a trimmer.
3. Thought Hallucination
Symptom: The agent's reasoning is coherent, but it calls the wrong tool or misinterprets the observation.
Cause: The model is pattern-matching on the thought format rather than reasoning from observations.
Fix: Use native function calling instead of text-parsed actions — it's structurally impossible to "hallucinate" a malformed tool call when the model outputs JSON. This is why modern LangGraph uses native function calling under the hood.
4. Attention Dilution
Symptom: The agent "forgets" earlier context and makes decisions inconsistent with earlier observations.
Cause: Long trajectories cause the model to weight recent context more heavily than early context.
Fix: Re-inject key facts at each step ("Remember: the user's budget is $500") or use a dedicated memory/state layer. See our guide to context engineering for AI agents for techniques.
ReAct in Production Frameworks (2026)
Most modern agent frameworks implement ReAct under the hood — often transparently:
| Framework | How ReAct Is Implemented |
|---|---|
| LangGraph | create_react_agent — stateful graph, native function calling, streaming |
| LangChain | AgentExecutor with create_react_agent prompt (legacy, still works) |
| CrewAI | Default agent loop is ReAct-compatible; uses LLM's function calling |
| AutoGen / AG2 | GroupChat with tool-use agents wrapping ReAct behavior |
| OpenAI Agents SDK | Native function calling = ReAct without text parsing overhead |
| Claude API | Tool use API provides native ReAct-equivalent behavior |
The original ReAct paper used text-parsed actions ("Action: search[query]"). Modern models support native function calling — the model outputs a structured JSON tool call instead of free-text. Native function calling is strictly better: no regex parsing, no malformed action errors, and the model is fine-tuned to use it correctly. When choosing a framework, prefer one that uses native function calling over text-parsed ReAct.
When NOT to Use ReAct
ReAct isn't always the right tool. Skip it when:
- The task is fully deterministic — use a pipeline or workflow (n8n, Make) instead of an LLM reasoning loop
- Token cost is critical — for tasks where the structure is known upfront, ReWOO or Plan-and-Execute will be 3–5x cheaper
- The task has no useful tools — pure reasoning tasks (math proofs, classification) work better with Chain-of-Thought
- Latency is paramount — each tool call adds a round-trip; a 5-step ReAct agent takes 5x longer than a single-call CoT response
For team-based workflows where you need multiple agents collaborating, ReAct is typically one node within a larger orchestration — not the entire architecture. See our guide to AI agent architecture patterns for the full picture.
Putting It All Together
The ReAct pattern is deceptively simple: reason, act, observe, repeat. But this loop is the foundation that lets an AI agent do things no pure language model can — query live data, write and run code, interact with APIs, and adapt to unexpected results.
In 2026, ReAct has evolved from text-parsed prompts to native function calling, from single-agent loops to sub-agents within larger multi-agent graphs. But the core insight from the original paper holds: grounding reasoning in real observations makes agents dramatically more reliable.
Whether you're building a personal automation agent or a production customer support system, understanding the ReAct loop means you can debug it when it breaks, optimize it when it's slow, and replace it with something better when the task calls for it.
cowork.ink gives your team a shared workspace for building, testing, and collaborating on AI agents — including ReAct-based workflows with real tool integrations. Set up your first agent in minutes.
Get Started
Ready to build your first ReAct agent? Start with LangGraph's create_react_agent for production use, or use the minimal Python implementation above for learning. For a deeper look at all agent reasoning patterns, see our guide to how AI agents reason.
Try cowork.ink free — collaborate on AI agents as a team, without the infrastructure headaches.