Skip to content
Techniques

ReAct Prompting: Think, Act, Check, Repeat

What ReAct (reasoning and acting) is, how the Thought, Action, Observation loop works, when it beats chain of thought, and prompts to run it by hand or in code.

Illustration of ReAct prompting: white outline loop of three clockwise arrows linking a thought bubble, a magnifying glass and an eye

Ask a chatbot about something that changed last month and it either admits it doesn't know or quietly makes something up. Ask it to compare two products using specs it has never seen and it guesses. The weak point usually isn't the reasoning. It's that the model is reasoning with nothing but its memory.

ReAct prompting fixes that by letting the model alternate between thinking and doing: write a thought, take an action such as a search, read what comes back, then think again. It's the pattern behind most AI agents and tool-using assistants. This guide explains how the loop works, when it beats plain chain of thought, and gives you prompts to run it by hand in ChatGPT, Claude or Gemini, or to wire it into code.

What ReAct prompting is

ReAct, short for "reasoning and acting", was introduced in October 2022 by Shunyu Yao and colleagues at Princeton University and Google Research, and published at ICLR 2023. Before it, models were prompted either to reason (think step by step, then answer) or to act (issue commands to a tool or environment), rarely both. ReAct interleaves the two.

Each turn of the loop has three parts:

  • Thought: the model reasons in plain language about what it knows, what's missing and what to do next.
  • Action: it picks exactly one action from a fixed list, such as searching, looking up a term or finishing with an answer.
  • Observation: the result of that action, written back into the conversation by a tool, a program or you.

Thoughts change nothing in the outside world; they update the model's plan. Actions do touch the world, and observations bring fresh information back. In the paper's words, reasoning helps the model "induce, track, and update action plans", while actions let it gather information from external sources.

The original experiments were deliberately simple. A frozen PaLM-540B model got a handful of worked examples and a basic Wikipedia API with three actions: search for a page, look up a phrase on that page, and finish with an answer. No fine-tuning, no special architecture. ReAct is a prompting pattern, which is why you can use it with any capable model today.

How the Thought, Action, Observation loop works

Here is a short trace in the style of the paper, for a question that needs two facts the model may not reliably remember. Observations are shortened.

Question: Which is older, the Eiffel Tower or the Statue of Liberty? Thought 1: I need the completion date of each. I'll start with the Eiffel Tower. Action 1: Search[Eiffel Tower] Observation 1: The Eiffel Tower is a wrought-iron lattice tower in Paris… built from 1887 to 1889. Thought 2: Completed in 1889. Now I need the Statue of Liberty. Action 2: Search[Statue of Liberty] Observation 2: The Statue of Liberty is a colossal sculpture on Liberty Island in New York Harbor… dedicated on 28 October 1886. Thought 3: 1886 is earlier than 1889, so the Statue of Liberty is older. Action 3: Finish[The Statue of Liberty (dedicated 1886) is older than the Eiffel Tower (completed 1889).]

Three things make this work. Each thought names what's missing, so the next action has a purpose. Each action is one small step in a fixed format, so a program (or a person) can carry it out without guessing. And the final answer rests on what was observed, not on what the model happened to remember.

The loop also gives the model a chance to recover. If the first search had returned the Eiffel Tower in Las Vegas, the next thought is where it can notice the mismatch and search again with a better query. A single chain of reasoning has no such checkpoint: once a wrong fact is in, every later step builds on it.

ReAct vs chain of thought vs acting alone

The paper compared ReAct with two simpler set-ups, and the contrast explains when to use each.

  • Chain of thought: reasoning only. Strong on logic and maths, but every fact comes from the model's memory. The authors found it more prone to hallucinated facts and to errors that spread through later steps.
  • Act only: actions and observations, no thoughts. The model searches, but it doesn't plan, combine results or notice when it's going round in circles.
  • ReAct: both. Thoughts decide what to look up; observations correct the thoughts.

ReAct beat acting alone on all four benchmarks. On FEVER, a fact-checking task, it also beat chain of thought (60.9% vs 56.3% accuracy). On HotpotQA, a multi-step question-answering task, it trailed chain of thought slightly (27.4 vs 29.4 exact match), mainly because unhelpful search results threw it off. The best scores came from combining the two: use ReAct, and fall back to chain-of-thought prompting with self-consistency when ReAct can't reach an answer, or the other way round.

The decision-making results were more striking. In ALFWorld, a text-based game where an agent completes household tasks, ReAct with two examples succeeded 71% of the time, against 37% for an imitation-learning method trained on around 100,000 examples. On WebShop, a simulated online shop, it reached 40% against 29.1%.

When ReAct is worth using

Most prompts don't need a loop. ReAct earns its keep when a task has these features:

  • The answer depends on information the model doesn't have: recent events, prices, your own documents, a live database.
  • Lookups depend on each other: the second search only makes sense once you've seen the result of the first.
  • There are tools to act with: web search, a calculator, code execution, a spreadsheet, an internal API.
  • You need an audit trail: you want to see why each step was taken, not just the final answer.

It's the wrong tool for pure writing tasks, for questions the model handles well from memory and for single lookups. If one retrieval step reliably finds the right documents, plain retrieval-augmented generation (RAG) is simpler, faster and cheaper.

Tip: Count the lookups before you choose. One lookup means search or RAG is enough. Several lookups where each depends on the last is exactly the case ReAct was designed for.

A ReAct prompt template you can copy

This template turns any chat model into a ReAct agent. Adjust the action list to the tools you actually have.

You solve tasks by alternating Thought, Action and Observation steps. Available actions: - Search[QUERY]: search [SOURCE, E.G. THE WEB OR OUR HELP CENTRE] and return the top results. - Lookup[TERM]: find TERM in the last page or document you opened. - Calculate[EXPRESSION]: work out a maths expression. - Finish[ANSWER]: give the final answer and stop. Format, repeated until you finish: Thought: what you know, what is missing, what you will do next Action: exactly one action from the list Observation: leave this empty; it will be filled in for you Rules: - One action per step, then stop and wait for the observation. - Never write an observation yourself. - If an observation is unhelpful, say so in your next thought and try a different query. - Stop after [8] actions and report what you found and what is still missing. - In Finish, say which observations your answer relies on. Task: [YOUR QUESTION]

Three lines do most of the work. The action list can use any names you like, but the format must be fixed so each action is easy to run. "Never write an observation yourself" is the most important rule: without it, models happily invent their own search results, which is just chain of thought pretending to use tools. And the step limit stops the model looping forever on a question it can't answer.

For harder or more specialised tasks, add one or two complete worked traces before the task, like the Eiffel Tower example above. The paper used between one and six examples depending on the benchmark, which is ordinary few-shot prompting: the examples teach the format and the style of thought better than any instruction.

Running ReAct by hand in a chat

You don't need code to try it. Paste the template into a chat, and each time the model writes an action, run it yourself: do the search, open the document, check the spreadsheet. Then paste the result back:

Observation: [PASTE THE RESULT, E.G. THE FIRST 3 SEARCH SNIPPETS OR THE RELEVANT PARAGRAPH] Continue with your next Thought and Action. One action, then wait.

It's slower than a normal chat, but it works with information the model can't reach, such as an intranet page or a PDF you can't share in full, and it shows you exactly where the model gets stuck. Suppose a customer asks whether a discontinued printer works with your new cartridges. The model asks to search the compatibility page, then to look up the printer's model number on it, then to check the returns policy. You decide what it sees at every step.

Assistants with built-in web search or file access already run a loop like this internally, but the steps are often hidden. You can bring the ReAct discipline back with a prompt:

Use web search to answer: [QUESTION] Before each search, write one line saying what you are looking for and why. After each search, write one line saying what you learned and whether it changes your plan. If two sources disagree, search once more to settle it before answering. End with the answer, a confidence level (high, medium or low) and the links you relied on.

The "before and after" lines are the thoughts; the searches are the actions. You get a readable trail, and the model is less likely to answer from the first result it finds.

Tip: Keep the action list and rules in a system prompt or custom instructions so every new chat starts with the same loop. The system prompt generator gives you a clean structure to start from.

ReAct in code and AI agents

The original implementation worked on plain text. The program let the model write until it reached "Observation:", read the action with a simple pattern match, ran it, appended the result and called the model again. Today most model APIs offer native tool calling (also called function calling): you describe each tool with a name and an argument schema, the model returns a structured tool call, your code runs it and sends the result back. The loop is the same; the parsing is far more robust. This loop is the core of most AI agents.

  1. Define a short list of tools with clear names, one-line descriptions and strict argument formats.
  2. Send the task with the tool definitions; the model replies with either a tool call or a final answer.
  3. Run the tool and return the result as the observation, then call the model again.
  4. Stop on a final answer, a step limit or a cost limit, whichever comes first.

If your model or platform has no tool calling, ask for each step as a small JSON object so your code can parse it reliably:

Reply with exactly one JSON object per step and nothing else: {"thought": "[YOUR REASONING]", "action": "[search | lookup | finish]", "input": "[QUERY, TERM OR FINAL ANSWER]"} Do not include an observation. Wait for it to be sent to you.

The JSON output prompt builder helps you write formats like this without loose ends. Whichever route you take, a few rules save a lot of pain: log every thought, action and observation; cut long observations down before they go back in, because a whole web page can fill the context window fast; check tool arguments before running them; and treat every observation as untrusted data. A web page or email can contain instructions aimed at the model, which is how prompt injection gets into agents.

Limits worth knowing

ReAct is a sound pattern, not a guarantee. Be clear about what it can't do.

  • Bad observations derail it: the paper found that unhelpful search results were a major cause of failure, and the model often struggled to recover. The loop is only as good as its tools.
  • It can get stuck in loops: repeating the same thought and action is a common failure. Step limits and a "try a different query" rule help, but don't remove it.
  • Thoughts are not proof: the written reasoning is a useful trail, not a guaranteed record of why the model chose an action. Check the observations, not just the story.
  • It costs time and tokens: every step is another model call, and observations pile up in the context. A five-step loop can take many times longer than a direct answer.
  • Actions have consequences: searching is harmless; sending emails, editing files or spending money is not. Give agents the smallest set of permissions and ask for human confirmation on anything irreversible.
  • The numbers are from 2022: one model, four benchmarks, before native tool calling and reasoning models. Modern models follow the loop far better, so test it on your own tasks rather than relying on the paper's figures.

Used where it fits, ReAct prompting turns "answer from memory" into "check, then answer". Start with the hand-run version on a question that needs two or three lookups and watch where the model goes wrong. If your problem is weighing options rather than finding facts, tree of thoughts prompting is the better fit.

References

Put this into practice. Apply what you just read with our free tool: Prompt Optimizer →
By AI enthusiast & advanced user

Jordi Benitez has been using AI tools day to day for years. No researcher, no academic title — just an advanced user who has spent enough hours prompting ChatGPT, Claude, Gemini and image models to know what actually works, and built GetEasyPrompt to share it in plain language.

FAQ

Frequently asked questions

ReAct (reasoning and acting) prompting asks a language model to alternate between written reasoning steps and actions such as searches or tool calls, reading the result of each action before deciding on the next step. It was introduced in 2022 by researchers at Princeton University and Google Research and is the basic loop behind most AI agents.
Chain of thought reasons step by step using only what the model already knows. ReAct adds actions between the reasoning steps, so the model can look up facts, run calculations or query tools and correct its plan based on what comes back. That makes it less prone to invented facts on tasks that need outside information, at the cost of more model calls.
Yes. Give the model a list of allowed actions and the Thought, Action, Observation format, tell it to stop after each action, then run the action yourself and paste the result back as the observation. Assistants with built-in web search already loop internally; you can ask them to explain what they are looking for before each search and what they learned after it.
Not exactly. ReAct is the prompting pattern: interleave reasoning, actions and observations until the task is done. Function calling, or tool calling, is an API feature that lets a model return a structured request to run a tool. Most modern agents implement the ReAct loop with native tool calling instead of parsing plain text.

Write your next prompt in seconds

Turn a rough idea into a clear, structured prompt any AI can follow. Free, private, and no account needed.

Open the Prompt OptimizerSee all tools