What it is
The ReAct loop is the simplest pattern an AI agent can use to get something done in steps. The name joins two words, Reasoning and Acting. Instead of answering in one go, the AI works in turns:
- Thought: it writes a short note to itself about what it knows so far and what it needs next.
- Action: it does one thing, such as running a search, opening a file, or asking a calculator.
- Observation: it reads what came back.
Then it goes round again: a new thought based on what it just learned, a new action, a new observation. It stops when a thought says "I now have enough to answer", and it gives its final answer.
The pattern comes from a research paper called "ReAct: Synergizing Reasoning and Acting in Language Models", posted online on 6 October 2022 and published at the ICLR 2023 conference. The lead author, Shunyu Yao, was a PhD student at Princeton University who did the work during an internship at Google. His co-authors were Karthik Narasimhan of Princeton and Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran and Yuan Cao of Google Research's Brain team. Almost every AI agent you can use today, from research assistants to coding agents, runs some version of their loop.
A detective at work
Think of a detective with a notebook. A bad detective sits in an armchair and announces who did it, based on hunches. A second kind of bad detective runs around collecting fingerprints and interviewing everyone in town, but never stops to ask what the evidence means. A good detective alternates: "The butler says he was in the kitchen. If that's true, someone else rang the bell. Let me check who had a key." They check. "Only the gardener had a key. Let me find out where the gardener was at nine." Each finding changes the next question.
That's the ReAct loop. The armchair detective is an AI using pure Chain of Thought: it reasons step by step, but only from what's already in its head, so if it misremembers a fact, the whole chain of reasoning is built on sand. The busy-but-thoughtless detective is an AI that only acts: it can call tools, but it has no plan and no running commentary, so it loses track of what it's doing. ReAct puts the two together.
The paper itself uses a kitchen example to make the same point. When you cook, you think between actions: everything's chopped, so the water can go on; there's no salt, so something else will have to do; you're not sure how to make the dough, so you'd better look it up. And you act to support your thinking: you open the fridge to see what's there before deciding what to make.
What a trace looks like
Written out, a ReAct run is called a trace, and it reads like a diary. Here's the example from the first figure of the paper, shortened. The question was: aside from the Apple Remote, what other device can control the program the Apple Remote was originally designed to interact with?
- Thought: I need to search Apple Remote and find the program it was designed for.
- Action: Search[Apple Remote]
- Observation: The Apple Remote is a remote control… originally designed to control the Front Row media center program.
- Thought: I need to search Front Row next.
- Action: Search[Front Row]
- Observation: Could not find [Front Row]. Similar: Front Row Seat to Earth, Front Row Motorsports, Front Row (software)…
- Thought: Front Row is not found. I need to search Front Row (software).
- Action: Search[Front Row (software)]
- Observation: Front Row is a discontinued media center software…
- Thought: Front Row is controlled by an Apple Remote or the keyboard function keys. So the answer is keyboard function keys.
- Action: Finish[keyboard function keys]
Notice two things. The failed search didn't derail it: the thought after the dead end picked a better search. And the final answer came from what it read, not from memory. In the same figure, the chain-of-thought version, reasoning from memory alone, confidently answered with a list of Apple devices and got it wrong.
Nothing magic is happening inside the model. It's the same language model predicting text. The difference is the structure around it: the software stops the model after each Action, runs the real tool, pastes the real result in as the Observation, and hands the whole growing trace back so the model can write the next Thought.
Why it matters
It's the engine inside most agents. When a chatbot says "Searching the web…" and then "Reading 4 sources…", and then changes its search, you're watching a ReAct-style loop. The Agent element describes the general cycle of goal, plan, act, observe; ReAct is the specific, widely copied recipe for how the thinking and the acting take turns.
It cuts down on made-up facts. Language models are good at sounding sure. When they reason from memory alone, a wrong "fact" early on gets carried through every later step, and the final answer inherits the mistake. ReAct makes the model go and check, then reason about what it actually found. That's a form of Grounding, and it's one of the most practical defences against Hallucination we have.
It adapts to surprises. A plan written in advance breaks the moment the world doesn't match it: a page has moved, a file is missing, a search returns nothing. Because a ReAct agent decides one step at a time, it can notice the dead end and try something else, as in the Front Row example above. Planning and ReAct are often combined for this reason: a plan for the big picture, a ReAct loop for each step.
You can read its mind, roughly. The Thought lines are written in plain language, so a person can follow the agent's reasoning, see where it went wrong, and correct it. In one example from the paper, a person edited just two of the agent's thoughts mid-run, removing a made-up claim and adding a hint, and the agent went on to succeed at a task it had been failing. Today this is part of how builders debug agents, and what Observability tools display. One caution: the written thoughts are the model's own account, and research has shown such accounts aren't always a faithful record of what drove the answer. Treat them as helpful notes, not a sworn statement.
It explains how agents fail. Once you know the loop, the common failures make sense: an agent that keeps repeating the same search is stuck in the loop, one that gives up too soon ended the loop early, and one that confidently reports nonsense probably trusted a bad observation. That knowledge makes you a much better supervisor of any AI that takes actions for you.
Real-world examples
The ReAct paper: Wikipedia questions and fact-checks (October 2022)
The researchers tested ReAct on Google's very large PaLM-540B model, using a few worked examples in the prompt rather than any retraining: six example traces for the question task and three for the fact-checking task. This is Few-shot prompting.
They gave the model a deliberately simple Wikipedia tool with three actions: search for a page (which returned its first five sentences, or suggested similar titles if there was no match), look up a word within the current page (like pressing Ctrl+F), and finish with an answer. They tested it on two benchmarks. HotpotQA is a set of questions that need facts from two or more Wikipedia pages to answer. FEVER is a set of claims to label as supported, refuted, or not enough information.
The results were more interesting than a simple "ReAct wins":
- On FEVER, ReAct beat chain of thought: 60.9% accuracy against 56.3%.
- On HotpotQA, ReAct on its own was slightly behind chain of thought (27.4 against 29.4 on exact-match answers). The acting-only version, with no thoughts, scored 25.7.
- The best scores came from combining the two, letting the model fall back from one method to the other when it wasn't confident: 35.1 on HotpotQA and 64.6% on FEVER.
The most revealing part was a hand check of 200 runs. When chain of thought got a HotpotQA question wrong, hallucination (made-up facts or reasoning) was the cause 56% of the time. For ReAct, hallucination caused none of the sampled failures. ReAct failed differently: 47% of its failures were reasoning errors, including getting stuck repeating the same thoughts and actions, and 23% came from searches that returned nothing useful, which threw the reasoning off. Among the answers each method got right, 14% of chain of thought's correct answers rested on hallucinated reasoning or facts, against 6% for ReAct.
That trade is the whole story of ReAct in miniature. Going to look things up makes the agent more honest, but it also makes it dependent on the quality of what it finds, and exposes it to loops.
A household game and an online shop (same paper, 2022)
The team also tested ReAct on two tasks that look more like modern agents at work.
ALFWorld is a text-based game in which the AI has to complete household chores in a simulated home, such as putting a pepper shaker in a drawer. It "sees" the room only as text, such as a line saying that on the countertop there's an apple, some bread, a pepper shaker and a vase, and it acts by typing short commands such as going to a cabinet or opening a drawer. WebShop is a simulated shopping site with 1.18 million real product listings, where the AI must find and buy an item that matches a request, such as a nightstand with drawers, a particular finish and a price limit.
With only one or two example traces in its prompt, the best ReAct run completed 71% of ALFWorld tasks. The best run of the same model acting without thoughts managed 45%, and a previous system trained specifically for the game on expert demonstrations managed 37%. On WebShop, ReAct bought a fully matching product 40% of the time, against about 29% for earlier methods trained on thousands of examples. Human experts still did far better, at about 60%, largely because they explored more products and rephrased their searches more.
The paper's figure shows exactly why the thoughts help. The acting-only agent goes to the sink, tries to take a pepper shaker that isn't there, is told "Nothing happens", and tries the identical action again. The ReAct agent first writes that a pepper shaker is more likely to be in a cabinet or on a countertop, checks those places, and finds it. The researchers reported that without thoughts, the agent failed to break goals into smaller steps and lost track of where it was.
From research idea to everyday tool (2023 onward)
The pattern spread fast. By March 2023, the documentation for LangChain, a popular free toolkit for building AI apps, listed agent types that "use the ReAct framework", including one that copied the paper's Wikipedia setup with Search and Lookup tools. LangChain's later LangGraph library shipped a ready-made create_react_agent helper, whose documentation describes the loop plainly: call the model, and if it asks for tools, run them, add the results, and call the model again, repeating until it stops asking for tools. At the time of writing, that helper has itself been superseded by a newer agent builder, which is a good reminder that the tools change quickly while the idea stays the same.
The biggest change since 2022 is that the loop moved inside the models. In the original paper, the model wrote "Action: Search[…]" as plain text and the software had to spot it. Modern models are trained to request tools in a structured way (see Function Calling), so the software knows exactly which tool to run and with what inputs. Newer "thinking" models go a step further. Anthropic's documentation, for example, describes interleaved thinking, which lets Claude think between tool calls, reasoning about each tool result before deciding what to do next. That's ReAct built into the product. Details differ between companies and change often, so check the current documentation for whichever tool you use.
Claude Plays Pokémon: when the loop goes round and round (February to March 2025)
On 25 February 2025, Anthropic launched "Claude Plays Pokémon" on the streaming site Twitch: its new Claude 3.7 Sonnet model playing the 1990s Game Boy game Pokémon Red, live. Anthropic said it had equipped the model with basic memory, the screen image, and function calls to press buttons and move around. In other words, a ReAct-style loop: look at the screen, think, press a button, see what happened, think again. It was a real step forward: Anthropic reported that an earlier Claude model couldn't even leave the starting house, while Claude 3.7 Sonnet won three of the game's gym badges.
It was also a public demonstration of how the loop can fail. News coverage reported that the model spent nearly 80 hours wandering a cave called Mt. Moon before finding its way out, and later kept insisting it needed to find a "gatehouse" rather than using the in-game ability that would clear its path. David Hershey, the Anthropic engineer behind the project, told Ars Technica that the model still wasn't good at understanding what was on the screen. Viewers documented it walking into walls, going round in circles, and at one point deleting its own notes about the cave after wrongly concluding it had already got through. Each of those is a classic ReAct failure: bad observations (misreading the screen), repeated actions, and a mistaken thought that ended a line of work too early.
An everyday scenario: the refund question
This is an illustrative scenario, not a documented case. Priya runs a small online craft shop and asks her AI assistant, which can search her help-desk inbox, whether a customer called Tom has already been refunded. A good ReAct run looks like this: Thought: I should search the inbox for Tom's order. Action: search "Tom refund". Observation: two emails, one asking for a refund and one from the payment company. Thought: the payment company email should confirm it; let me open it. Action: open email. Observation: "Refund of £24.00 processed on 3 June." Thought: that answers it. Answer: yes, refunded on 3 June, and here's the email.
A bad run: the first search returns nothing because the customer's name is spelled "Thom", and the assistant concludes "No refund found", which is stopping too early on a bad observation. The fix Priya learns is to ask the assistant to show its steps and to try a second search before concluding that something doesn't exist.
Try it yourself
You'll run a ReAct loop by hand. The chatbot does the thinking, and you play the tool. It can't see your document; it has to ask you to look things up. This shows you exactly what an agent's software does behind the scenes, and it works in any chatbot on a free plan.
- Pick a document with facts in it. Something a few pages long that you have open in another window: your phone contract, a product manual, a company handbook, a long article, or your own website's terms. Don't paste it into the chat.
- Think of a question that needs two or more facts to answer. Good ones: "If I cancel my contract in month 8, how much will I pay in total?" or "Which of the manual's cleaning steps apply to the model I own?" Questions like this force more than one lookup.
- Start the loop. Copy and paste this, filling in the brackets: > Let's run a ReAct loop. You are the reasoning agent, and I am your only tool. I have a document called [name of document] that you cannot see. Your job is to answer this question: [your question]. > > Work in turns. Each turn, write exactly two lines and then stop and wait for me: > Thought: what you know so far and what you need next. > Action: one of: SEARCH[a word or phrase] (I'll paste the sentences around that phrase), READ[a section name or heading] (I'll paste that section), or FINISH[your answer]. > > Rules: never answer from your own general knowledge; only from what I paste back. If an Observation doesn't help, say so in your next Thought and try a different Action. Take at most 8 turns.
- Answer each Action as the tool. When it writes SEARCH[early termination], press Ctrl+F in your document, find that phrase and paste back a few sentences around it, starting with "Observation:". If the phrase isn't there, reply "Observation: no results." Be a fair tool: paste what's actually there, not what you think it needs.
- Watch the thoughts. Notice how each Thought uses the last Observation. When you reply "no results", does it try a better search, as in the Front Row example, or does it repeat itself?
- Test a failure on purpose. Start a new chat and run the same question, but this time give one misleading Observation, such as an old price from a different section. Then paste: > Before you finish, look back over every Observation. Do any of them conflict with each other or look out of date? Which one is your answer relying on most? This shows you how much a ReAct agent depends on the quality of what its tools return, and how a good check can catch it.
- Compare with no tools. In a fresh chat, ask the same question with no document at all. Notice how the model either admits it can't know, or produces a plausible-sounding guess. That guess is the "armchair detective" that ReAct was invented to avoid.
- Check the final answer yourself. Look up the facts in the document directly. You played the tool, so you know exactly which facts it saw.
Once you've done this, watch the "searching" and "reading" messages next time you use a chatbot's web search or research mode. You'll recognise the same Thought, Action, Observation rhythm, just automated.
Common mistakes and misunderstandings
"ReAct is a product or an app." It's a pattern, a way of arranging the work, not something you download. Many products use it, usually without naming it.
"The written thoughts show exactly how the AI decided." They're useful, and far better than no explanation, but they're text the model generated, not a direct window into its inner workings. Use them to spot mistakes, not as proof that the reasoning was sound.
"More steps means a better answer." Not necessarily. The researchers capped their question runs at seven steps, and their fact-check runs at five, because they found more steps didn't improve the results. A long trace is often a sign of trouble: the same search being repeated with tiny changes, or an agent wandering because it has lost track of the goal. Sensible agent software sets a maximum number of steps, and so should you when you ask an agent to work. LangGraph's ready-made agent, for example, stops with a "need more steps" message rather than running forever.
"If it searched, it must be right." ReAct makes an AI check its facts, but it can only be as good as what it finds. A search that returns an old page, a misread screen, or a wrong result from a tool will be reasoned about just as confidently as a right one. In the paper, unhelpful searches caused almost a quarter of ReAct's failures. Always ask which sources the answer rests on.
Stopping too early. Agents sometimes treat "I didn't find it" as "it doesn't exist", as in the refund scenario. When the answer matters, tell the agent to try at least two different searches before concluding something is missing.
Getting stuck in a loop. The paper named this as the most frequent ReAct-specific error: the model repeating its previous thoughts and actions and failing to break out. If you see an agent doing the same thing twice, step in. Give it a new piece of information, suggest a different approach, or restart with a clearer goal. This is Human in the Loop at its simplest.
"ReAct and chain of thought are rivals." They're partners. Chain of thought is thinking without looking; ReAct is thinking while looking. The paper's best results came from combining them, and modern thinking models do both.
"Every task needs an agent loop." A simple question the model can answer reliably, or a fixed sequence of steps you already know, doesn't need a loop. Prompt Chaining is cheaper and more predictable when the steps never change. Save ReAct for tasks where the next step depends on what you just found.
Related elements
- Agent: the bigger picture of AI systems that take actions toward a goal, which ReAct makes work.
- Chain of Thought: the reason-only half of ReAct, and what it looks like without tools.
- Tool Use: the actions in the loop, from search to calculators.
- Function Calling: how modern models request a tool in a structured way instead of plain text.
- Planning: deciding the steps in advance, often combined with a ReAct loop for each step.
- Self-critique: including Reflexion, which added reflection on failed attempts to ReAct-style agents.
- Grounding: tying answers to real sources, which the Observation step provides.
- Hallucination: the problem ReAct was designed to reduce.
- Memory: how an agent keeps track of what it has done when a loop runs for many steps.
- Observability: the tools that let builders read an agent's trace and see where it went wrong.
- Web Search: the most common action in everyday ReAct loops.