# What Is ReAct Prompting?

> What ReAct prompting is, the think, act, observe loop, how it differs from chain-of-thought, and where it falls short, explained for your AI interview.

**In short:** ReAct prompting makes a language model take turns: it writes a short thought, asks a tool for one action, reads the result, then thinks again. It came from a 2022 paper, and it keeps answers tied to real lookups instead of memory alone.

AI and LLM interview question Q091, Prompt and context engineering. Intermediate, common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/what-is-react-prompting

## Say it in 30 seconds

ReAct is a prompt style where the model takes turns. It writes a short thought, asks a tool for one action, reads the result, and thinks again. The name joins reasoning and acting. The idea comes from a 2022 paper, and its main point is that the reasoning stays tied to real lookups. The cost is extra calls, so I use it only when the answer depends on outside facts.

## Say it in 2 minutes

ReAct is a prompt style where the model works in turns. It writes a short thought, asks a tool for one action, reads what comes back, and then thinks again. The name joins reasoning and acting. The idea comes from a 2022 paper, and the key point is that the model's plan is based on real results.

Here is how I'd explain it. Take a card dispute. A customer says a hotel charged her twice. The model thinks, then asks the lookup tool for her transactions. The tool returns two rows, one pending and one posted. The next thought uses that real data, so the model doesn't guess. Your code runs the tools it offers, so it can check each call first.

Compared with chain-of-thought alone, ReAct pulls in outside facts, and the paper found its reasoning trail more factual and grounded. Plain reasoning was often better at building the argument itself. The cost is more model calls, more time and more money, and fixed steps make the approach less flexible.

So I use it when the answer depends on facts the model can't know, and I cap the number of steps. If the cap is hit, a person takes the case, with the notes so far.

## What is ReAct prompting, in plain words?

A language model answers from what it learnt in training, and without tools it can't look anything up by itself. ReAct changes the shape of the reply. The model writes a short thought, asks a tool for one action, such as a lookup, reads what the tool returned, then thinks again. It repeats until it has enough to answer. An older method, called chain-of-thought, has the model write out its reasoning step by step, but only from what it already knows.

Think of a claims handler at an insurer. They don't decide from memory. They note what the claim says, pull the policy, read the cover, then choose the next check. Each lookup changes the next move. ReAct asks the model to work the same way, with every step written down.

- **Thought:** A short written step where the model works out what to do next.
- **Action:** A call to a tool, such as a lookup or a search. Your code runs it.
- **Observation:** What the tool sent back. It goes into the next turn.
- **Tool:** A function your app offers the model, like a policy lookup.
- **Final answer:** The reply the model gives once it has enough evidence.

## How does the think, act, observe loop work?

Each turn has three parts. The model writes a thought, which is a plan in plain words. It then picks one action. Your code runs that action and sends back the observation, and the next thought can use it. The loop ends when the model writes a final answer instead of another action. A ReAct prompt first shows the model a few worked examples of thoughts and actions, and the model then follows that pattern.

> "we explore the use of LLMs to generate both reasoning traces and task-specific actions in an interleaved manner" (Yao and colleagues, the ReAct paper (abstract))
>
> "The model can't run your code, so every tool call is a round trip: the model asks, you execute, you report back, the model continues." (Anthropic, tool use docs)

*Diagram, The ReAct loop: The model writes a thought, asks a tool for one action, and reads the observation that comes back. It repeats until it has enough to answer. Each pass lets the next thought use real results, not guesses from memory.*
1. The user's question goes in as one message.
2. The model asks for one action, such as a lookup.
3. The tool's result comes back as an observation.
4. Once the evidence is enough, the model answers.

The paper's own examples show the same trail: the model's thoughts and actions, and what the environment returned. Here is one made-up case for a bank's card team, step by step.

1. **The customer's claim:** A customer says a hotel charged her card £186 twice on 20 November. The assistant has to decide whether to refund.
2. **Thought, then action:** Two identical charges on one day, so the transaction log comes first. The model asks the lookup tool for card 4417.
3. **Observation:** The tool returns two rows for the same hotel and amount: one charge is pending, the other is posted.
4. **Thought, then final answer:** A pending row can be a hold that clears by itself, so a refund now would be premature. The answer: no refund yet, recheck in three days.

## How is it different from chain-of-thought and tool calls alone?

- **Reason only: Chain-of-thought.** The model thinks step by step, but only from its own memory. Nothing checks a fact, so an invented detail can slip in.
- **Act only: Tool calls, no written plan.** The model calls tools without writing down why. The trail is harder to follow, and a bad result is harder to spot.
- **ReAct: Both, in turns.** Each action is planned in writing, and each result shapes the next plan. Answers stay tied to what the tools returned.

Google's research blog said that plain chain-of-thought is not tied to the outside world. The model relies on its own internal representations, which limits its ability to reactively explore and reason or update its knowledge.

The paper's tests show the trade-off. The approach that acts on outside results gave a more factual and grounded trail, while plain chain-of-thought was more accurate at building the reasoning structure. The paper tested ReAct on question answering and fact checking. Its error check of the trade-off used HotpotQA, with 50 sampled trajectories per method.

The paper's best result came from combining the two: ReAct plus chain-of-thought, using both internal knowledge and outside results.

## What are the limits of ReAct?

ReAct is not free. Each turn is another model call, so it takes more time and money than a single answer. Fixed steps also make the reasoning less flexible. The paper says that this structure can cause more reasoning errors than chain-of-thought.

A loop can also run too long. If a tool keeps returning nothing useful, the model may keep searching. So you cap the number of steps, and send the case to a person when the cap is hit.

> **Tip:** Asked when to use it? Say it fits when the answer depends on outside facts the model can't know. Say you would skip it for a simple rewrite of text, where one call does the job.

## What does a ReAct loop look like in code?

Here is the same card case as a short Python loop. A script plays the model, so you can see the loop itself. In a real app, a model call would produce each thought and action.

```python
# A tiny ReAct loop. A script plays the model, so the output is the same every run.
TRANSACTIONS = {
    "4417": [
        "Harbour Hotel 186.00 pending",
        "Harbour Hotel 186.00 posted",
    ],
}

def lookup_transactions(card):
    return TRANSACTIONS.get(card, ["no rows"])

TOOLS = {"lookup_transactions": lookup_transactions}

# Each turn is (thought, action, input). The script stands in for the model's replies.
SCRIPT = [
    ("Two identical charges on one day. I need the log first.", "lookup_transactions", "4417"),
    ("One is pending. A pending row can be a hold, so check again before refunding.", "finish", "No refund yet. Recheck in 3 days."),
]

for thought, action, arg in SCRIPT:
    print("Thought:", thought)
    if action == "finish":
        print("Final answer:", arg)
        break
    result = TOOLS[action](arg)
    print("Action:", action + "(" + arg + ")")
    print("Observation:", result)
```

Output:

```text
Thought: Two identical charges on one day. I need the log first.
Action: lookup_transactions(4417)
Observation: ['Harbour Hotel 186.00 pending', 'Harbour Hotel 186.00 posted']
Thought: One is pending. A pending row can be a hold, so check again before refunding.
Final answer: No refund yet. Recheck in 3 days.
```

The loop runs each action, prints what came back, and stops on the final answer. In a real app that result goes back into the model's next prompt. Your code owns the tools, so it can limit or block any call before it runs.

### How would you stop a ReAct agent from looping forever?

Set a step limit, so a stuck agent stops after a fixed number of turns. The paper names repeated thoughts and actions as an error pattern specific to ReAct, so watch for the same action repeated with the same input, and treat that as stuck. When it stops, hand the case to a person with the notes so far, instead of letting the model guess.

> **Tip:** A short answer: cap the steps, catch repeats, then hand over to a person.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] A plain definition: the model writes a thought, takes one action, and reads the result.
- [ ] What ReAct adds: outside facts from tools, and a written plan a person can read.
- [ ] Where it is weak: more calls, more cost, and less flexible reasoning.
- [ ] How it differs from chain-of-thought alone, and from tool calls alone.
- [ ] Safety: a step cap, repeat checks and a handover to a person.

**Common traps**

- Trap: "ReAct is just chain-of-thought with a different name." Better: Chain-of-thought uses only memory. ReAct also takes actions and reads what they return.
- Trap: "The model runs the tools itself." Better: The model only asks. Your code runs the tool and sends back the observation.
- Trap: "More thinking steps always make it more accurate." Better: Each extra step is another model call, so it adds cost. The paper also found that ReAct's fixed structure led to more reasoning errors than chain-of-thought.

## Can you spot the right step?

**Spot the best next step:** Your claims agent has the policy number and the claim date, but it hasn't read the policy record yet. What is the best next step?

A. Write the final decision from memory of similar claims.
B. Call the policy lookup, then read the result before deciding.
C. Call every tool at once and sort out the order later.
D. Ask the model to explain its last answer in more detail.

**Answer:** B. The next thought should use real data. Deciding from memory skips the check. Calling every tool at once skips the order that makes each result useful, and repeating the last answer adds nothing new.

**Quick check:** Which part of a ReAct turn brings new facts into the model's context?

A. The thought
B. The action and the observation it returns
C. The temperature setting
D. The length of the system prompt

**Answer:** B. The action reaches a real tool, and the observation brings the result back. A thought only reasons over what the model already holds.

## Can you answer these from memory?

**Flash cards**

- **What is ReAct prompting?** The model alternates a written thought, one tool action, and the result it gets back.
- **What does ReAct stand for?** Reason and act: reasoning steps mixed with real actions.
- **What is an observation?** What the tool sends back. It goes into the next turn.
- **Who runs the tool?** Your code. The model only asks for the action.
- **How is it different from chain-of-thought?** Chain-of-thought uses only memory. ReAct also reads outside results.
- **What is its main cost?** More model calls, so more time and money, which is why steps get capped.

## Likely follow-up questions

- Q078 What is chain-of-thought, and when does it help? https://designervenkat.online/interview/ai/what-is-chain-of-thought-prompting
- Q160 What is the agent loop? https://designervenkat.online/interview/ai/what-is-the-agent-loop
- Q156 What is tool (function) calling? https://designervenkat.online/interview/ai/what-is-tool-calling
- Q173 How do you stop endless agent loops? https://designervenkat.online/interview/ai/how-do-you-stop-endless-agent-loops
- Q090 What is self-consistency? (full answer coming)
- Q092 What is prompt chaining? https://designervenkat.online/interview/ai/what-is-prompt-chaining

## Learn it in depth

- [ReAct](https://designervenkat.online/learn/ai-engineering/react)
