How does ReAct (Reasoning and Acting) prompting work?
Intermediate · 2 min read · Prompt Engineering
Open in study mode to save this question and track progressShort answer: ReAct (Reasoning + Acting) is a prompting technique that combines Chain-of-Thought reasoning with external action/tool execution in an interleaved loop (Thought → Action → Observation → Thought), allowing LLMs to solve complex tasks dynamically.
Detail
Standard Chain-of-Thought (CoT) prompting encourages the model to generate internal reasoning steps before outputting a final answer. However, CoT is limited by the model's static parameter memory and cannot inspect real-world databases, call APIs, or handle dynamic environment changes.
ReAct bridges reasoning and execution by structuring prompt generation into discrete steps:
- Thought: The model analyzes the current context, sub-goal, and what information is missing.
- Action: The model emits a structured command or tool call (e.g.,
Search[query],ExecuteSQL[query],Calculator[expression]). - Observation: The external system runs the tool and appends the result back into the conversation context as an
Observation. - Repeat: The model reads the new observation and generates the next
Thought, continuing until it reaches a finalThoughtand outputsFinish[answer].
User Query
│
▼
┌───────┐
│Thought│ ──► "I need to check stock price of Apple."
└───────┘
│
▼
┌───────┐
│Action │ ──► GetStockPrice("AAPL")
└───────┘
│
▼
┌───────────┐
│Observation│ ──► "$224.50" (Result returned by API)
└───────────┘
│
▼
┌───────┐
│Thought│ ──► "Now I have the price. I can return the final answer."
└───────┘
│
▼
Finish
Why ReAct is central to AI Engineering
- Explainability: Human developers can inspect the model's reasoning trajectory step-by-step.
- Error Recovery: If an action returns an error or empty result, the subsequent
Thoughtstep allows the LLM to modify its search query or try an alternative tool. - Groundedness: Reduces hallucinations by grounding answers in retrieved observations rather than parametric memory.
Example
Prompt template structure for a ReAct agent:
You operate in a loop of Thought, Action, Observation, Thought. Available Tools: - Search[query]: Searches the internet for information. - Calculator[expression]: Evaluates a mathematical expression. Format your response strictly as follows: Thought: <reasoning about what to do> Action: <ToolName[argument]> When you have the final answer, format it as: Thought: I know the final answer. Final Answer: <your response> User Question: What is the age of the current President of France multiplied by 2? Thought: First I need to find out who the current President of France is and their age. Action: Search[current President of France age] Observation: Emmanuel Macron, born 21 December 1977 (age 48 as of August 2026). Thought: I found Emmanuel Macron's age (48). Now I need to multiply it by 2. Action: Calculator[48 * 2] Observation: 96 Thought: I have calculated the final result. Final Answer: The age of the current President of France multiplied by 2 is 96.
Interview tips
- Contrast ReAct with pure zero-shot tool calling (Function Calling API): ReAct explicitly surfaces reasoning tokens prior to tool execution, improving tool argument selection accuracy.
- Discuss common failure modes: infinite loops (model repeatedly trying broken tools), context window overflow from long observation outputs, and high API costs.