ReAct Prompting

Authors 5 articles 54 min total read
Definition
ReAct Prompting is a framework where a language model interleaves explicit reasoning traces with external tool calls, cycling through Thought, Action, and Observation steps to solve multi-step tasks that require live information or computation.
Also called: Reason+Act prompting, ReAct agent loop, thought-action-observation prompting

What ReAct prompting is

ReAct prompting exists because a language model on its own can reason but cannot act. It can think through a problem step by step, but it has no way to check a live price, run a query, or call an API mid-answer. ReAct fixes that by giving the model a structured format that alternates between thinking and doing — making the Thought–Action–Observation loop the core mechanism behind modern AI agents.

The name stands for “Reasoning + Acting,” introduced in a 2022 research paper that showed language models solve tasks more accurately when they interleave reasoning traces with tool calls. A model prompted with the ReAct format does not just produce a final answer — it generates a sequence of alternating steps:

  • Thought: The model reasons about what to do next. (“I need to find the current exchange rate to convert this amount correctly.”)
  • Action: The model calls a tool — a search engine, a calculator, an API, or a code interpreter. (“search: current USD to EUR exchange rate”)
  • Observation: The tool’s result is fed back into the context. (“1 USD = 0.92 EUR as of today”)

The loop repeats until the model reaches a final answer, or a maximum step count is hit. Think of it like a developer following a whiteboard runbook: write the next step, execute it, read the output, write the next step — rather than trying to hold everything in memory at once.

This structure separates ReAct from two simpler approaches. Pure chain-of-thought prompting generates a reasoning trace but never calls any external tool — everything stays inside the context window. Pure action-based execution calls tools in a fixed sequence but does not let the model reason between steps about which action to take next. ReAct combines both: the model’s reasoning determines which action to take, and the action’s result shapes the next round of reasoning.

The result is a framework where the model can solve problems that depend on information it does not have at generation time — current prices, live documentation, database records, or the output of code it just ran. The three-phase Thought–Action–Observation cycle is not scaffolding around the main idea; it is the main idea. Every capability that makes an AI agent useful in practice — searching, checking, computing, filing — runs through this loop.

The model's own reasoning picks each tool call, so every loop needs a clear stop condition and a narrow tool set. · More AI cheat sheets
  • Understanding the Thought-Action-Observation loop is how you diagnose why an agent looped, picked the wrong tool, or stalled — even when the loop itself is hidden inside a framework’s API contract.
  • Four documented failure modes limit ReAct in production, and none of them show up in a demo running the happy path.
  • Native function calling now handles simple, well-defined lookups faster; ReAct still earns its place for open-ended, multi-step reasoning you need to audit.
  • In 2026 the loop rarely appears as literal prompt text — it is built into agent frameworks and API contracts, which is why LangChain deprecated its standalone AgentExecutor.

How ReAct prompting is used in practice

The most common place people encounter ReAct is inside AI assistant tools and coding agents. When you ask an AI assistant “What’s the latest release of framework X and what changed since the previous version?”, the model does not guess from training data. A ReAct-based agent thinks through what it needs, calls a web search or documentation API, reads the result, and then composes its answer from actual retrieved content — not from stale memory.

Framework builders use ReAct as the default agent loop in tools like LangChain, LlamaIndex, and PydanticAI. These libraries handle the loop plumbing — parsing the model’s Action output, dispatching the right tool, feeding the Observation back into context — so developers only need to define which tools the agent can call and when to stop.

The Thought step is doing more work than it appears. If the agent makes bad decisions, read the thoughts first — they show exactly where the reasoning went wrong and which tool call followed from a false assumption. Thought traces are not verbose output; they are a built-in debugger.

The ReAct reading path: loop mechanics before agent debates

Start with what ReAct prompting is and how the Thought-Action-Observation loop gives LLMs the ability to act — it is the one article in this topic allowed to explain the mechanism, and everything downstream assumes you have read it. Follow immediately with the prerequisite concepts and failure modes explainer: it maps what breaks before you write a single line of agent code, which is cheaper to learn from a page than from a production incident.

Once the mechanism and its limits are clear, the Python build guide turns them into a working loop and gives the decision framework for when a plain function call beats the extra reasoning step. For where the pattern actually landed, ReAct in the wild tracks how coding agents absorbed the loop into their API contracts rather than retiring it. Close with the accountability risks of ReAct-based agents acting without consent before you let one take an irreversible action in production.

MONA asks: 'My ReAct agent called the same search tool four times in a row for one question — is that a bug?' MAX answers: 'Not a bug. That's the loop working exactly as built, with no termination condition to stop it.' — comic dialog.
A ReAct loop without an explicit stop condition isn't malfunctioning — it's doing precisely what it was told.

How ReAct differs from its closest neighbours

Three confusions recur once teams start building agent loops.

ReAct is not the same decision as native function calling. Function calling lets a model emit a structured call in one shot; ReAct wraps that call inside an explicit reasoning step before and after it. The two are not exclusive — the production pattern in the build guide is hybrid: a fast function call for a simple lookup, a full ReAct loop only when the next step actually depends on what the last tool returned.

ReAct and prompt chaining are not rivals to pick between. Production pipelines increasingly nest one inside the other: a chain handles the stages you can fix in advance, and a ReAct loop takes over for the one stage where the right next tool depends on what just came back. Treating them as an either/or choice is what leads teams to over-engineer a chain into handling runtime branching it was never built for.

ReAct is not tree of thoughts with tools bolted on. Tree of thoughts explores several hypothetical reasoning branches and scores them before committing to one — none of it touches a real system. ReAct commits to one action per cycle and only finds out if it was right when the environment responds. Confusing the two produces agents that either burn compute exploring branches nobody asked for, or systems that expect a single ReAct call to plan the way a full search would.

When ReAct prompting fits — and when it doesn't

ScenarioUseAvoid
Multi-step task needing live information (prices, docs, APIs)✅
Simple one-turn Q&A from known training data❌
Coding agent that needs to read files, run tests, check errors✅
Summarizing a document already in the context window❌
Tasks where tool call results change what to do next (dynamic path)✅
Tasks with a fixed, predictable sequence of steps❌

Common questions about ReAct prompting

Q: Can a prompt chain and a ReAct loop run in the same pipeline, or do you have to choose one? A: They compose rather than compete — the production pattern in the build guide chains fixed stages together and drops into a ReAct loop only for the one step whose next move depends on a tool’s response. Most real agents mix both rather than picking a single pattern outright.

Q: When does tree of thoughts beat a ReAct loop for a reasoning problem? A: When the problem needs several hypothetical paths compared before any real action, and scoring a partial answer is cheap — tree of thoughts explores those branches without touching a live tool. ReAct is the better fit once the next step genuinely depends on what an external system returns, not on further internal deliberation.

Q: Why does a ReAct agent keep calling the same tool with slightly different inputs instead of stopping? A: Because nothing told it when to stop — the prerequisite failure-modes explainer documents this as one of four recurring breakdowns, and the fix is an explicit termination condition, not a smarter model.

Q: How often do adversarial attacks actually succeed at hijacking a deployed ReAct agent’s actions? A: In one controlled study probing thirty deployed agents with over a thousand attack attempts, roughly one in four succeeded under standard conditions — nearly double with a reinforced attack, a rate the consent and accountability risks piece argues most deployments aren’t governed for.

Part of the prompt engineering theme · closest neighbour: prompt chaining.

1

Understand the Fundamentals

ReAct Prompting structures LLM outputs as a repeating Thought–Action–Observation loop, giving the model a way to reason, act on external tools, and correct course rather than producing a single static response.

2

Build with ReAct Prompting

The guides here cover implementing a ReAct loop from scratch, choosing between a hand-rolled pattern and native function calling, and the trade-offs that decide which approach fits a given use case.

4

Risks and Considerations

ReAct-based agents can take irreversible external actions without explicit user consent at each step—understanding where accountability sits and how to constrain action scope is essential before deploying these systems.