What is ReAct Prompting?

ReAct (Reasoning and Acting) is a prompting paradigm introduced by Yao et al. in 2022 that synergizes two capabilities that were traditionally separate: reasoning (Chain-of-Thought) and acting (tool use). The model follows a structured cycle:

  • Thought: The model reasons about what it knows and what it needs to do next.
  • Action: The model calls an external tool (search, calculator, code executor, API).
  • Observation: The model receives and processes the tool's output.

This cycle repeats until the model has enough information to produce a final answer. ReAct is the conceptual backbone of most modern AI agent architectures, including LangChain's agent module, OpenAI's function calling, and Anthropic's tool use API.

The key insight is that interleaving reasoning with real observations makes the model's actions more purposeful (it thinks before acting) and its reasoning more grounded (it updates based on real results, not hallucinated facts).

When to Use ReAct Prompting

🔍

Research Tasks

Multi-step information gathering where the model needs to search, synthesize, and verify facts from multiple sources before answering.

🧮

Calculations & Data Analysis

Tasks requiring numeric computation, where the model should call a calculator or code interpreter rather than hallucinate arithmetic.

🤖

Autonomous AI Agents

Agents that must take actions in systems (send email, update CRM, query database) based on reasoning about their state and goals.

🛒

E-commerce & Product Research

Price comparison, product lookup, and recommendation tasks that require live data retrieval combined with analytical reasoning.

🗃️

Database Interaction

Query generation, result interpretation, and iterative refinement of database queries based on intermediate results.

📅

Task Orchestration

Complex workflows where the next step depends on the result of the previous step — calendar scheduling, resource allocation, multi-system coordination.

How to Implement ReAct

  1. 1

    Define available tools

    List the actions the model can take and describe each tool: its name, what it does, its input format, and what it returns. The model needs this to reason about which tool to use.

  2. 2

    Provide a Thought/Action/Observation example

    Show the model the exact format to follow with one worked example. This establishes the structural pattern before the model begins the actual task.

  3. 3

    Present the task and let the model begin

    The model generates a Thought and an Action. Your code (or you manually) executes the action, captures the result, and appends it as an Observation. Feed this back to the model.

  4. 4

    Repeat until Final Answer

    Continue the Thought → Action → Observation cycle until the model generates a "Final Answer" response. Add stopping conditions (max iterations, confidence threshold) to prevent infinite loops.

Prompt Examples

ReAct Trace Format
You have access to these tools:
- search(query): Search the web and return relevant excerpts
- calculate(expression): Evaluate a mathematical expression
- lookup(entity): Get a Wikipedia summary of an entity

Use the Thought/Action/Observation format. When done, write "Final Answer: ..."

Question: What is the population of the capital of France,
and how does that compare to the population of Berlin?

Thought: I need to find the capital of France and its population,
then find Berlin's population to compare.
Action: lookup("Paris")
Observation: Paris is the capital of France with a population
of approximately 2.1 million in the city proper (11M metro).

Thought: Now I need Berlin's population.
Action: lookup("Berlin")
Observation: Berlin is Germany's capital with ~3.7M city population.

Thought: I have both figures. Paris city: 2.1M, Berlin: 3.7M.
Berlin is larger by ~1.6M people (76% more than Paris city proper).
Final Answer: Paris has ~2.1M residents vs. Berlin's ~3.7M.
Berlin is approximately 76% more populous than Paris (city proper).
Single-Prompt ReAct Simulation
Simulate a ReAct agent solving this research task step by step.
For each step, show:
Thought: [your reasoning]
Action: [what tool you'd call and with what input]
Observation: [what result you'd expect]

Continue until you reach a Final Answer.

Task: Find the current market leader in the vector database space,
identify their main differentiator, and estimate their market share
relative to the top 3 competitors.

Pros and Cons

🟢 Pros🔴 Cons
Grounds reasoning in real, external data — reduces hallucinationRequires tool infrastructure — not usable without integrations
Enables truly autonomous agent behaviorMore complex to implement than pure prompting techniques
Reasoning traces make agent behavior interpretable and debuggableMultiple model calls increase latency and cost
Foundation of production AI agent frameworksPoor tool design leads to poor agent behavior

Frequently Asked Questions

What is ReAct Prompting?

ReAct (Reasoning + Acting) is a prompting framework where the model interleaves reasoning traces with concrete actions in a cyclical pattern: Thought → Action → Observation → Thought → Action → Observation... The model explicitly reasons about what to do next (Thought), takes an action like a search or calculation (Action), and then processes the result (Observation) before reasoning again. This cycle continues until the task is complete.

What does ReAct stand for?

ReAct stands for Reasoning and Acting. It was introduced by Yao et al. in a 2022 paper and demonstrates that synergizing reasoning traces with task-specific actions improves both performance and interpretability on tasks requiring tool use, information retrieval, and decision-making.

When should I use ReAct Prompting?

ReAct is ideal when the task requires gathering external information (web search, database queries), performing computations (calculators, code interpreters), taking actions in an environment (API calls, file operations), or making sequences of decisions based on intermediate results. It is the foundation of most modern AI agent architectures.

What is the difference between ReAct and Chain-of-Thought?

Chain-of-Thought produces reasoning in a single forward pass — the model thinks and then answers without external input. ReAct interleaves reasoning with actual actions and real observations, allowing the model to gather new information mid-task. CoT is for self-contained reasoning; ReAct is for tasks requiring interaction with the world.

How do I implement ReAct without an agent framework?

In a single prompt or conversation, you can simulate ReAct by explicitly formatting your prompt with Thought/Action/Observation headers. Ask the model to generate a Thought and Action, then you (or your code) provide the Observation, and the cycle continues. Many developers use LangChain, LlamaIndex, or custom orchestration code to automate this loop.

What actions can a ReAct agent take?

Actions depend on the tools available: web search (Google, Bing API), Wikipedia lookup, code execution (Python interpreter), calculator, database queries, file read/write, API calls (weather, stock prices, CRM systems), and any custom tool you define. The power of ReAct comes from the agent's ability to choose the right tool at the right time.

What are the limitations of ReAct?

ReAct requires tool infrastructure — it cannot be used without defining and connecting actual action capabilities. It produces more tokens per task than CoT (due to explicit reasoning traces). Tool errors can cascade if not handled properly. And the model's reasoning quality determines whether it selects the right actions — poor reasoning leads to poor tool usage.