The ReAct agent pattern combines language model reasoning with real-world actions to solve complex problems. It enables a model to create a plan, execute part of it, observe the outcome, and then adjust its plan accordingly. This iterative loop allows agents to adapt and handle tasks that require up-to-date information or interaction with external systems.

Key takeaways

  • ReAct is a design pattern, not a specific framework. It combines Reasoning with Acting by interleaving a model's thought process with calls to external tools.
  • The core engine is a Thought → Action → Observation loop. This allows an agent to gather information, execute tasks, and adapt its plan based on external feedback.
  • This pattern is effective for complex, multi-step tasks that require information gathering or interaction with an environment to find a solution.
  • Production systems require safeguards like step limits, timeouts, and action validation to prevent errors, high costs, and infinite loops (Source).
  • For simple, predictable tasks, a ReAct loop can add unnecessary latency and complexity compared to a more direct approach like single-turn LLM Tool Calling: How It Works and How to Use It.

What is the ReAct agent pattern?

The ReAct agent pattern is a design for building AI agents that solve problems by interleaving reasoning with actions. ReAct stands for Reasoning and Acting. Instead of trying to generate a final answer in one step, a ReAct agent breaks a problem down, takes a small step (an action), observes the result, and then reasons about what to do next. This allows the agent to adapt its plan.

At its core, the ReAct pattern gives a language model a process for thinking and acting iteratively (Source). An AI agent using this pattern can use external tools to get information it doesn't have, such as searching a database or checking a live API. It then uses the results of those actions to inform its next thought and subsequent action. This dynamic feedback loop allows the agent to correct its own mistakes and navigate tasks where the solution path is not obvious from the start.

It is helpful to think of ReAct as a general architecture, not a specific piece of software. The original research demonstrated the pattern on four benchmark environments: HotpotQA, FEVER, ALFWorld, and WebShop (Source). Many different frameworks and custom implementations can use this pattern.

How does the ReAct loop work, step by step?

The ReAct agent pattern follows a simple, iterative cycle: it thinks, it acts, and it observes the result. The agent repeats this loop until it has enough information to answer the user's request or hits a predefined limit. The language model itself does not execute code; a separate part of the system is responsible for running the action the model specifies.

Here is a breakdown of the typical Thought-Action-Observation loop:

  1. Task and Tools: The process begins with a user's task and a list of available tools. Each tool must have a clear name and description so the language model understands what it can do (e.g., search_web(query: string) or get_stock_price(ticker: string)).

  2. Thought Generation: The model receives the task, tool descriptions, and the history of previous steps (if any). It generates an internal thought, which is its reasoning about the current state and what to do next. This thought process might include breaking the problem down or identifying missing information.

  3. Action Selection: Based on its thought, the model outputs a specific, machine-readable action. This is typically a JSON object specifying the tool to use and the arguments to pass to it, like {\"tool\": \"search_web\", \"arguments\": {\"query\": \"latest AI research\"}}.

  4. Action Execution: The application code receives the action from the model. It validates the action, checks permissions, and then executes the corresponding tool. For example, it might call a web search API. The language model itself never executes the tool.

  5. Observation: The result of the action—whether data, a success message, or an error—is formatted into a simple "Observation" string. This observation is sent back to the language model. For example: Observation: "The latest AI research includes papers on diffusion models and agentic workflows."

  6. Repeat or Conclude: The model appends the observation to its history and returns to Step 2. It reasons about the new information to decide the next action. This loop continues until the model determines it has the final answer or a safety limit, like a maximum number of steps, is reached.

A worked example: Tracing a ReAct agent in action

A ReAct agent's ability to adapt and self-correct is central to its design. To see how, let's trace an agent solving a problem, including how it handles an error.

Task: "What is the current temperature in the capital of Australia?"

Available Tools:

  • search(query: string): Searches the web for information.
  • get_weather(city: string): Gets the current temperature for a specific city.

Here is the step-by-step execution trace.

Loop 1: Find the capital city

  • Thought: I need to find the capital of Australia first. The user did not provide the city name. I should use the search tool for this.
  • Action: search(query='capital of Australia')
  • Observation: The tool executes and returns: Canberra

The agent now appends this observation to its history.

Loop 2: Get the weather (with an error)

  • Thought: Now I know the capital is Canberra. I need to get the weather for this city. I should use the get_weather tool. I will pass the city name I just found.
  • Action: get_weather(city='Canberra, Australia')
  • Observation: The weather tool is strict and expects only a city name. It fails and returns an error: Error: City not found. Please provide city name only.

This is a critical moment. A less sophisticated system might fail completely. But a ReAct agent can use this error as new information.

Loop 3: Correct the action and retry

  • Thought: The previous action failed because the city name was formatted incorrectly. The error message says to provide the city name only. I need to call the get_weather tool again with just "Canberra".
  • Action: get_weather(city='Canberra')
  • Observation: The tool executes successfully and returns: 12°C

Conclusion: Formulate the final answer

  • Thought: I have successfully found the capital of Australia (Canberra) and its current temperature (12°C). I now have all the information needed to answer the user's question. I will generate the final answer.
  • Final Answer: The current temperature in Canberra, the capital of Australia, is 12°C.

This example shows how the observation phase allows the agent to diagnose and recover from problems, making it much more reliable for real-world tasks.

ReAct vs. other agent architectures

The ReAct agent pattern is just one way to design an AI agent. Understanding how it compares to other common approaches helps you choose the right tool for your task. Simpler alternatives are often better when the full adaptability of ReAct is not needed.

Architecture Description Best For
ReAct Pattern Interleaves reasoning, action, and observation in a loop. Adapts its plan after each step. Complex, dynamic tasks where the solution path is unknown at the start and requires gathering external information.
Reasoning-only (Chain-of-Thought) Generates a step-by-step reasoning trace to guide its final answer but does not use external tools. Logic puzzles, math problems, or summarization tasks where all necessary information is in the initial context.
Single-Turn Tool Calling The model identifies and calls one or more tools in a single turn. It does not loop. Simple tasks where the required tool and its arguments are immediately obvious from the user's query.
Fixed Upfront Planning The model first generates a complete, multi-step plan of actions and then executes that sequence without modification. Predictable, multi-step workflows in a stable environment where you don't expect errors or surprises.

When should you not use the ReAct pattern?

The ReAct pattern adds overhead and is not always the best choice. For some tasks, it introduces unnecessary complexity, latency, and cost (Source). You should consider a simpler approach in the following situations.

For fixed, deterministic workflows

If the sequence of operations is always the same, a simple script or a directed workflow is more efficient and reliable. For example, if you always need to fetch a user's profile, check their order history, and then send an email, you don't need a language model to decide those steps every time. A standard software function is better.

For latency-sensitive applications

Each step in a ReAct loop adds a round-trip to the language model, which increases the total response time. If a user is waiting for an immediate answer and the task can be solved with a single tool call, that direct approach is more efficient. ReAct is better for background tasks or situations where thoroughness is more important than speed.

For simple information retrieval

If a user's query maps directly to a single tool or API call (e.g., "What's the weather in London?"), a ReAct loop is overkill. The system can directly parse the user's intent, call the get_weather(city='London') tool, and return the answer. This is faster and cheaper than initiating a multi-step reasoning process.

Essential safeguards for production ReAct agents

Deploying a ReAct agent without proper safeguards is risky. Because the agent operates in a loop, it can potentially run for too long, spend too much money, or perform unintended actions. Before using a ReAct agent in a production application, implement these critical checks.

  • Maximum Step Count: Always set a hard limit on the number of Thought-Action-Observation cycles. A reasonable limit (e.g., 5-10 steps) prevents infinite loops and contains costs.
  • Timeouts: Enforce a total time limit for the entire task. If the agent doesn't finish within a certain period (e.g., 30 seconds), the process should be terminated automatically.
  • Action Validation: Never blindly execute an action proposed by the model. Validate that the tool name is valid and that all arguments match the expected schema (e.g., correct data types, within valid ranges). The model can hallucinate tools or arguments (Source).
  • Permissions and Scoping: Limit the agent's capabilities. Only provide it with the tools necessary for its designated function. If a tool can modify data, ensure it has the minimum required permissions and consider adding a human approval step for sensitive actions.
  • Cost and Token Budgeting: Track the token usage and associated costs for each run. Set a budget and stop the process if it's exceeded. This is crucial for preventing unexpectedly large bills.

Current State

As of November 2026, ReAct remains a foundational, simple agent pattern for sequential tool use. Current engineering guidance emphasizes that it is not a universal architecture. Practical systems require bounded loops, validation for tools and outputs, permission controls, error recovery, and explicit cost and latency management to be effective and safe in production (Source, Source).

Open Questions and Future Directions

While the ReAct pattern is widely used, several open questions remain in the field of AI agent development. Key challenges include:

  • Developing better evaluation metrics that consider the safety and correctness of an agent's intermediate actions, not just the final answer.
  • Understanding when an adaptive, step-by-step ReAct loop is more efficient than generating a complete plan upfront.
  • Managing an agent's context and memory over long-running tasks to prevent performance degradation.
  • Creating robust methods for validating tool arguments and detecting hallucinated actions from the language model.

What to learn next

Sources and further reading