What is ReAct?
ReAct is an agent pattern in which a language model alternates reasoning steps with tool actions while solving a task, taking each action's result as an observation and building its next thought on it.
The name comes from Reasoning and Acting. Unlike chain of thought, which is step-by-step reasoning inside the model alone, ReAct combines reasoning with tool calls and corrects itself with real information at each step. The agent loop is the general pattern ReAct runs within.
- Topic
- Agents and protocols
- Also known as
- Reasoning and Acting, ReAct prompting
- Origin
- 2022, Yao et al.
How ReAct works
- Thought: the model assesses the task and current information, writing what it needs to do.
- Action: the model picks a tool and writes its parameters, such as a search or database query.
- Observation: the runtime executes the action and returns the result to the model.
- The loop repeats until the model judges it has enough information to write a final answer or a limit is reached.
In more detail
From parsed text to native tool calling
Originally introduced in 2022 as a text-prompting pattern ('Thought:... Action:... Observation:...') parsed with regular expressions, modern implementations combine native structured tool calling (JSON schemas) with built-in reasoning tokens interleaved between tool invocations. This eliminates brittle text-parsing failures while keeping the core loop intact.
Tool errors, loop breakers and idempotency
Real tools fail, return empty sets or time out. Production ReAct loops require structured error observations returned to the model, maximum iteration caps, duplicate-action loop detection and idempotency guards so repeated retries do not duplicate side effects such as creating two tickets or bookings.
Context bloat and parallel tool calling
Because each ReAct step appends the full thought, action and observation to the prompt, context length grows rapidly and every iteration triggers a new model pass. On multi-tool tasks, parallel tool calling or hybrid plan-then-act architectures often cut latency and token cost substantially.
Indirect prompt injection via observations and least privilege
Because tool observations come from external databases, tickets or web pages, they can carry indirect prompt injections that hijack the next action. Applying least-privilege tool scopes and requiring human confirmation before destructive or state-changing actions mitigates this risk.
Commonly confused terms
| Term | How it differs |
|---|---|
| Plan-and-execute | ReAct plans dynamically one step at a time after each observation, whereas Plan-and-Execute generates a multi-step plan up front before running tools, reducing round-trips on predictable workflows. |
| Reflexion | ReAct combines reasoning and acting within a task-solving loop, whereas Reflexion adds an explicit self-evaluation and episodic memory step across failed attempts so the agent learns from mistakes between trials. |
Why ReAct matters for on-premises AI
ReAct aids auditing of in-house agents: the thought written before each action shows why a tool was chosen, leaving a loggable trace. Observations come from real systems, so answers rest on current data rather than the model's memory. Written thoughts may not mirror the model's internal computation exactly, a limit to keep in mind when using them as explanations. Each turn adds tokens and latency, so step limits and cost tracking are needed.
A hospital's administrative assistant first reasons about which department an appointment question needs, calls the clinic calendar tool, observes free slots then answers from it; every step is logged.
Common questions
How does ReAct differ from chain of thought?
Chain of thought is step-by-step reasoning inside the model only. ReAct alternates reasoning with tool actions, each action's result feeding the next thought.
Are ReAct thoughts the model's real reasons?
Not always. Written thoughts leave a useful trace, but there is no guarantee they exactly explain the model's internal computation; audits should account for this.
Related terms
Sources
- Yao et al., ReAct: Synergizing Reasoning and Acting in Language Models, 2022
- Wei et al., Chain-of-Thought Prompting Elicits Reasoning in Large Language Models, 2022
In the glossary: Glossary, R to Z