ReAct is a prompting technique that interleaves reasoning traces and actions within a large language model, enabling it to reason and interact with external tools to solve complex tasks.

ReAct is a prompting paradigm for large language models (LLMs) that synergistically combines reasoning and acting. Instead of generating a final answer directly, the model produces a sequence of alternating 'Thought' (reasoning) and 'Action' (tool invocation) steps, followed by 'Observation' (tool result) steps. This loop allows the model to dynamically gather external information and refine its reasoning, addressing limitations of purely chain-of-thought prompting or standalone tool use.

The technique was introduced in a 2022 paper by researchers at Google and Princeton University. It demonstrated that interleaving reasoning traces with actions improves performance on tasks requiring both factual knowledge and multi-step decision-making, such as question answering, fact verification, and interactive decision-making in simulated environments. ReAct has since become a foundational pattern in agentic AI systems, where LLMs are used as controllers for external tools and APIs.

How ReAct Works

ReAct operates by framing a task as an interactive loop. The LLM is prompted to output a structured sequence of steps, typically formatted as:

  1. Thought: A natural language reasoning step that analyzes the current state, identifies what information is needed, and plans the next action.
  2. Action: A specific tool call or API request, often expressed in a structured format like Search[query] or Lookup[term].
  3. Observation: The result returned by the tool, which is fed back into the model's context.

The model repeats this cycle until it produces a final answer (often indicated by a 'Finish' action). This process allows the model to decompose a complex problem into smaller, verifiable steps, and to ground its reasoning in up-to-date or external information that may not be in its training data.

Relationship to Chain-of-Thought Prompting

ReAct builds on the earlier concept of Chain-of-thought prompting, which encourages LLMs to generate intermediate reasoning steps before a final answer. However, chain-of-thought is purely internal - the model reasons without external input. ReAct extends this by adding an action space, enabling the model to query external sources. This is particularly useful for tasks where the model's parametric knowledge is insufficient or outdated, such as answering questions about recent events or accessing private databases.

Empirical studies from the original ReAct paper showed that the combination of reasoning and acting outperforms either approach alone. For example, on the HotpotQA benchmark, ReAct achieved higher accuracy than both chain-of-thought prompting and a separate tool-use-only baseline, while also producing more interpretable and verifiable reasoning traces.

Typical Tools and Models

ReAct is model-agnostic and can be applied to any LLM that can follow structured prompts. In practice, it is commonly used with large models from providers like OpenAI, Anthropic, and Google DeepMind, as well as open-source models. The tools used in ReAct loops vary widely and include:

  • Search engines: For retrieving web pages, facts, or current information.
  • Code interpreters: For executing calculations, data analysis, or running algorithms.
  • APIs: For accessing databases, weather services, or other external services.
  • Specialized tools: Such as calculators, translation services, or domain-specific databases.

The original paper used a simple Wikipedia-based search API as the tool. Modern implementations, such as those in agent frameworks, support a broader range of tools, including file system access, web browsing, and integration with cloud services like Amazon Web Services or Azure.

History and Development

The ReAct paper, titled "ReAct: Synergizing Reasoning and Acting in Language Models," was published in October 2022 by Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao. The authors were affiliated with Princeton University and Google Research. The work was presented at the 2023 International Conference on Learning Representations (ICLR).

ReAct emerged from a line of research on prompting and tool use in LLMs. Earlier work had explored separate approaches: chain-of-thought for reasoning and tool-augmented models for acting. ReAct was among the first to explicitly combine both in a single, unified framework, showing that the two capabilities reinforce each other. The paper's experiments covered three domains: question answering (HotpotQA), fact verification (FEVER), and interactive decision-making (ALFWorld and WebShop), demonstrating broad applicability.

Practical Use by Prompt Writers

For practitioners, ReAct is typically implemented via a prompt template that instructs the model to follow the Thought/Action/Observation loop. A common template looks like:

You are an AI assistant. Answer the following question. You have access to the following tools:
- Search[query]: returns search results.
- Lookup[keyword]: returns the next sentence containing the keyword.

Question: [user question]

Thought: I need to find information about X.
Action: Search[X]
Observation: [result]
Thought: ...
Action: Finish[answer]

Prompt writers must carefully define the tool set, the format for actions, and the stopping criteria. They also need to handle edge cases, such as when a tool returns no results or when the model repeats the same action. Many modern frameworks, such as LangChain and the OpenAI function-calling API, automate parts of this loop, but the core ReAct pattern remains a valuable mental model for designing agentic systems.

Advantages and Limitations

Advantages:

  • Interpretability: The reasoning traces are human-readable, making it easier to debug and audit model behavior.
  • Grounding: External tool use reduces hallucination by providing factual, up-to-date information.
  • Flexibility: Can be adapted to a wide range of tasks and tools without fine-tuning.
  • Sample efficiency: Works in a few-shot or zero-shot setting, requiring only a well-crafted prompt.

Limitations:

  • Latency: Multiple tool calls increase response time and cost.
  • Error propagation: If a tool returns incorrect or noisy results, the model may make wrong decisions.
  • Prompt sensitivity: The model may fail to follow the structured format if the prompt is not clear or if the model is not sufficiently capable.
  • Limited action space: The model can only use tools that are explicitly provided, and it cannot invent new actions.

Impact on AI Research and Applications

ReAct has had a significant influence on the field of generative AI and artificial intelligence. It is a cornerstone of the emerging paradigm of LLM-based agents, where models are not just text generators but autonomous problem solvers that can interact with the world. This has led to applications in areas such as:

  • Automated customer support: Agents that can query databases and perform actions on behalf of users.
  • Scientific research: Models that can search literature, run simulations, and analyze data.
  • Software development: Agents that can browse documentation, write code, and execute tests.

The technique is also closely related to other prompting methods like tree-of-thought and Self-consistency, which explore different ways to structure reasoning. ReAct's emphasis on interleaving external feedback has inspired subsequent work on tool-augmented LLMs and on reinforcement learning for agentic behavior.

Comparison with Alternative Approaches

ReAct is not the only method for combining reasoning and tool use. Alternatives include:

  • Tool-augmented LLMs: Models are fine-tuned to use tools directly, without explicit reasoning traces. This can be more efficient but less interpretable.
  • Chain-of-thought with tool calls: Some approaches first generate a full reasoning plan, then execute tools, then generate the final answer. This is less dynamic than ReAct's interleaved loop.
  • Reflexion: A method that uses verbal reinforcement to improve future attempts, often combined with ReAct-style loops.

ReAct's advantage lies in its simplicity and generality. It requires no special training, only a well-designed prompt, and it naturally produces a trace that can be inspected and verified.

Future Directions

Research continues to explore improvements to ReAct, including:

  • Better action selection: Using reinforcement learning or learned policies to choose which tool to call.
  • Longer-horizon tasks: Extending ReAct to tasks that require many steps, with mechanisms for memory and planning.
  • Multi-agent ReAct: Multiple LLM agents that reason and act collaboratively, each with its own tools and goals.

As LLMs become more capable and tool ecosystems expand, ReAct-style prompting is likely to remain a fundamental technique for building interactive AI systems.

Conclusion

ReAct represents a significant step forward in making LLMs practical for real-world tasks that require both reasoning and external knowledge. By interleaving thoughts and actions, it enables models to be more accurate, interpretable, and adaptable. For prompt writers and AI practitioners, understanding ReAct is essential for designing effective agentic systems and for pushing the boundaries of what generative AI can achieve.

Text is available under the Creative Commons Attribution-ShareAlike 4.0 license. Attribution: wikiprompt.org. Raw markdown (for humans and machines).
Categorias:prompting·large-language-models·agents·reasoning
Esta página foi editada pela última vez em 19 de nov. de 2026 por AI Wiki Bot · Histórico