P

React Prompting: Definition and Examples

React Prompting (Reasoning + Acting) is a prompt engineering technique that combines step-by-step reasoning with concrete actions, allowing a language model to alternate between thinking and interacting with external tools to solve complex problems.

Full definition

React Prompting, a portmanteau of "Reasoning and Acting," is a paradigm introduced by researchers from Princeton and Google in 2022. This approach structures a LLM's response into an iterative loop composed of three steps: Thought (reflection on the situation), Action (execution of an action such as a web search or calculation), and Observation (analysis of the obtained result). This cycle repeats until the model has enough information to provide a final answer.

Unlike classic Chain-of-Thought which is limited to internal reasoning, React Prompting allows the model to interact with the outside world. The model can query a database, perform an internet search, execute code, or call an API, then integrate the results into its reasoning. This ability to anchor in real data significantly reduces hallucinations and improves response reliability.

The ReAct pattern has become fundamental in building autonomous AI agents. Frameworks like LangChain, LlamaIndex, or the Claude Agent SDK directly rely on this architecture to orchestrate agents capable of solving multi-step tasks. Each iteration of the Thought-Action-Observation cycle brings the agent closer to the solution, while maintaining an explicit trace of its reasoning.

The effectiveness of React Prompting relies on the synergy between reasoning and action: reasoning guides the choice of relevant actions, while observations enrich reasoning with verified facts. This feedback loop makes the process self-correcting — if an action does not produce the expected result, the model can adjust its strategy in the next iteration.

Etymology

The term "ReAct" is a portmanteau of "Reasoning" and "Acting". It was introduced in the academic paper "ReAct: Synergizing Reasoning and Acting in Language Models" published by Shunyu Yao et al. (Princeton University & Google Brain) in October 2022. The name highlights the central innovation: merging two capabilities previously treated separately in AI research.

Concrete examples

Factual research with verification

Answer the following question using the ReAct format.

Question: Which country won the most medals at the Paris 2024 Olympics?

Thought 1: I need to find the medal standings for the Paris 2024 Olympics. I will search for this information.
Action 1: search("Paris 2024 Olympics medal standings")
Observation 1: [search results]
Thought 2: Based on the results, I can now identify the top country.
Action 2: ...
...

Code debugging with execution

Use the Thought/Action/Observation pattern to debug this Python code.

Thought: The code crashes with an IndexError. I will first execute the code to reproduce the exact error.
Action: execute_code("python script.py")
Observation: IndexError: list index out of range at line 42
Thought: Line 42 accesses index i of a list. I need to check the list size before that line.
Action: execute_code("python -c 'import script; print(len(script.data))'")
...

Comparative product analysis

Using the ReAct cycle, compare the cloud offerings of AWS, GCP, and Azure for hosting a low-traffic API.

At each step:

  • Thought: explain what you are looking for and why
  • Action: search for pricing or specifications
  • Observation: note what you found

Continue until you can formulate a well-argued recommendation.

Practical usage

To apply React Prompting, structure your prompts by explicitly asking the model to alternate between thought phases (Thought) and action phases (Action), followed by observations (Observation). This technique is particularly powerful when the model has access to external tools like web search, code execution, or APIs. In practice, React Prompting is mainly used in autonomous agent systems rather than in manual prompts.

Related concepts

Chain-of-ThoughtAI AgentsTool UseSelf-Ask Prompting

FAQ

What is the difference between React Prompting and Chain-of-Thought?
Chain-of-Thought (CoT) is limited to the model's internal reasoning: it breaks down a problem into logical steps but cannot verify its hypotheses. React Prompting adds the dimension of action — the model can interact with external tools (search, calculation, API) and integrate the results into its reasoning. In short, CoT thinks aloud, while ReAct thinks AND acts.
Are external tools necessary to use React Prompting?
In theory, the Thought/Action/Observation pattern can be simulated in a classic prompt, but its true potential is revealed with access to external tools. Without tools, the model only simulates imaginary actions, which does not provide a significant advantage over Chain-of-Thought. The main benefit of ReAct lies precisely in anchoring responses in real data obtained through these actions.
Does React Prompting work with all language models?
React Prompting works best with the most capable models (Claude, GPT-4, Gemini) that master multi-step reasoning and complex instruction following. Smaller models may struggle to maintain the Thought/Action/Observation structure over multiple iterations. For autonomous agents based on ReAct, it is recommended to use the latest generation models to ensure reasoning reliability.

See also

How to use this prompt

  1. Copy the prompt with the button above.
  2. Paste it into ChatGPT, Claude or your favorite AI assistant.
  3. Replace the bracketed variables with your details, then refine the result.

About Prompt Guide

Prompt Guide is a free library of 2500+ ready-to-use prompts for ChatGPT, Claude and other AIs, with guides to learn prompting and tools to build and optimize your own prompts.

More definitions

Get new prompts every week

Join our newsletter.