What Is ReAct for Agents?
How ReAct works inside an AI agent: thought, action and observation, how they map onto tool calls, and where the pattern goes wrong, for your AI interview.
In short
ReAct is the pattern where an agent works in steps: it writes a short thought, takes one action such as a tool call, reads the observation that comes back, and repeats until the goal is met. It lets the agent check facts outside the model, but a wrong thought can still carry forward.
12 min readIntermediateCommon · estimateFacts checked 26 November 2026
Say it out loud
Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.
ReAct is a way to build an agent that works in steps. Each step has a thought, which is a short plan, then one action, usually a tool call, then an observation, which is what the tool sent back. The agent repeats this until the goal is met. It helps because the agent checks facts outside the model. But a wrong thought can carry forward, so I log every step and cap the number of steps.
An agent is a model that uses tools to finish a job, like reading a file or checking a record. Left alone, it can act on a guess. ReAct fixes the shape of its work. Each step has three parts: a thought, which is a short plan in plain words, an action, which is one tool call, and an observation, which is the tool's result. The next thought reads that observation before it decides anything.
The 2022 paper that introduced it tested this on fact checking and on interactive tasks. Its main point was that the written reasoning helps the model track its plan, while the actions let it check facts outside itself. In the Claude API, the action is a tool_use block that your code runs, and your code sends back a tool_result as the observation.
The weak point is the thought itself. It is text the model wrote, so it can be wrong, and a wrong thought can carry forward through later steps. The Google Research post shows a run that failed on a made-up thought, and a person fixed two of the thoughts so it finished. I check the observations and the final result, and treat each thought as a claim to test.
In production I keep a log of every thought, action and observation. I check tool arguments in code, cap the steps, and stop on a repeated action so a person can take over. I also test on real cases, because an agent can look right on one example and still fail on the next.
What is ReAct for agents, in plain words?
A chatbot answers in one go, from what it learnt in training. An agent does work: it reads files, looks things up and acts. ReAct is a simple way to shape that work. Each step has a thought, an action and an observation.
The 2022 paper that introduced it is called Synergizing Reasoning and Acting in Language Models. The Google Research post on ReAct says the task-solving trajectory consists of multiple reasoning-action-observation steps.
Think of a pharmacist checking a repeat prescription. They note what must be confirmed, check the record, read what it says, and pick the next check. What the record says changes that next check. ReAct asks an agent to work the same way.
Here is a real case. A coding agent in a CI pipeline sees a failing date test. Its thought: it needs to see what the test expects. Its action: read the test file. Its observation: the test reads 03/04/2026 as 3 April. Its next thought: the parser reads month first, so the fix goes there.
Key words
- Thought
- A short plan in plain words, written before each action.
- Action
- One step the agent takes, usually a tool call such as a record lookup.
- Observation
- What the tool sent back, which the next thought reads.
- Tool
- A function your code runs for the model, like a file reader or a policy lookup.
- Agent
- A model that uses tools and its own results to finish a job, with its own control over the next step.
How does one ReAct step fit into an agent?
In the Claude API, a ReAct step shows up in the response and in the message you send back. Read the three steps in order, then the chart.
- 1
Thought
In ReAct the model writes a short plan in words, before it asks for a tool. Keep that text in your log, since it shows what the agent was trying to do.
- 2
Action
The Claude API sends back a tool_use block, a chunk of data with the tool name and its arguments. Your code runs the tool, and the model only asks for it.
- 3
Observation
Your code sends back a tool_result. The model reads it before writing its next thought.
One ReAct step in tool-calling terms
Task and tool list
what it must finish and may call
Model
writes a thought, then one action
Your code
Runs the tool
sends back a tool_result
Final answer
the answer the user reads
- 1The task and the tool list go in.
- 2The model writes a thought, then asks for one tool.
- 3Your code runs it and sends back the result, the observation.
- 4When the goal is met, the model gives the final answer.
OpenAI's function calling guide describes a similar loop, with different names. The model's request is a tool call, and the result that comes back is a tool call output. With its Responses API, OpenAI says your application can keep going for as many tool calls as the task requires.
Why does the thought help, and is it better than the other ways?
There are three simple ways for a model to work, and each one fails in its own way.
- Thought only
Answers from memory
The model reasons with no outside check, so a made-up fact can slip through unnoticed.
- Action only
Calls tools with no plan
Tool calls follow one another with no written plan, so a surprising result has nothing to check it against.
- ReAct
Plans, checks, adjusts
Each thought uses the last observation, and each action tests the current plan.
“reasoning traces help the model induce, track, and update action plans as well as handle exceptions”
The ReAct paper
“ReAct enables language models to generate both verbal reasoning traces and text actions in an interleaved manner.”
Google Research
On HotpotQA, a question answering test with a Wikipedia lookup, ReAct beat plain action generation and was competitive with chain of thought, which writes out its reasoning with no lookups. The paper says the lookups help against hallucination (a confident, made-up answer) and against the error build-up that plain reasoning suffers from.
On two interactive tests, ALFWorld and WebShop, where the agent acts in a household simulator or an online shop, the paper reports gains of 34% and 10% in success rate, measured in percentage points, over imitation learning, where the model copies examples, and reinforcement learning, where it learns from rewards.
What does a tiny ReAct loop look like in code?
Here is a short loop for a CI agent with a failing date test. A script plays the model, so the output is the same every run. The marked lines are the step cap and the repeat guard that stop a stuck agent.
# A tiny ReAct loop for a CI agent with a failing date test. A script plays the model.
MAX_STEPS = 4
FILES = {"test_orders.py": "expects 03/04/2026 to mean 3 April"}
def read_file(name):
return FILES.get(name, "file not found")
TOOLS = {"read_file": read_file}
# Each turn is (thought, action, input). The script stands in for the model.
SCRIPT = [
("The date test fails. I need the test's expectation.", "read_file", "test_orders.py"),
("Still unclear. I will read the same file again.", "read_file", "test_orders.py"),
("Fix the parser to read day first.", "finish", "Change parse_date to day-first."),
]
seen = set()
for step in range(MAX_STEPS):
thought, action, arg = SCRIPT[step]
print("Thought:", thought)
if action == "finish":
print("Final answer:", arg)
break
if (action, arg) in seen:
print("Stopped: same action twice. A person takes over.")
break
seen.add((action, arg))
print("Action:", action, arg)
print("Observation:", TOOLS[action](arg))Output
Thought: The date test fails. I need the test's expectation. Action: read_file test_orders.py Observation: expects 03/04/2026 to mean 3 April Thought: Still unclear. I will read the same file again. Stopped: same action twice. A person takes over.
The agent asked for the same file twice, so the guard stopped the run and handed it to a person. The loop never reached the fix, and that is the right result for a stuck agent: it should stop and hand over. A real agent would call a model at each step, and your code would still own the tools and the guard.
Where does a ReAct agent go wrong?
The thought is written by the model, so it can be wrong. The Google Research post shows a run that failed because of a hallucinating reasoning trace. A person then edited two of the thoughts, and the run finished.
A wrong thought carries forward
Later steps build on it, and a new observation may not fix the plan.
Loops
The same action runs again and again. Anthropic's guide on building agents, dated December 2024, says it is common to add stopping conditions, such as a maximum number of iterations, to maintain control. The guide notes that much of its tooling has changed since then, so treat this as the principle, not the current tooling.
Cost and time
Each step is another model call, and the log grows with every observation.
Tip
Asked about the weakness? Say the thought is a claim to check. Then check the observation and the final result.
How would you keep a ReAct agent on track in production?
- 1
Log every step
Keep each thought, tool call and observation with a time stamp, so a failed run can be replayed.
- 2
Check tool calls in code
Validate the arguments before a tool runs, so a wrong claim number is rejected before it is sent on.
- 3
Cap the steps
A step limit stops a runaway loop. A repeated action, the same tool with the same input, sends the case to a person.
- 4
Ask a person before risky actions
Payments and emails wait for approval, and the check lives in code.
- 5
Test in a sandbox, then on real cases
Anthropic's December 2024 guide recommends extensive testing in sandboxed environments, with guardrails in place.
What does the interviewer want to hear?
A strong answer covers
- A plain definition: a loop of thought, action and observation.
- How it maps to the Claude API: a tool_use block out, a tool_result back.
- Why it helps: the agent checks facts outside the model.
- Where it fails: a wrong thought carries forward, and loops cost money.
- The controls: a step cap, a repeat check, logs, and a person for risky steps.
- Honest scope: ReAct helps, but no pattern guarantees a correct answer.
Common traps
Trap"ReAct makes the model reason better now."
BetterIt is a loop pattern. Reasoning traces help the model track and update its plan and handle exceptions, and the real tool results keep it grounded.
Trap"The thought proves why the agent acted."
BetterThe thought is text the model wrote. Judge the run by its observations and its final result.
Trap"More steps always means a better answer."
BetterEach step costs a model call and can add a wrong idea. Set a cap and measure the results.
Can you spot the bad step?
Spot the bad step
Which step has a thought that goes beyond what the agent has observed?
Quick check
An observation says the policy number was not found, but the next thought assumes the policy is active. What should your code do?
Can you answer these from memory?
Flash cards · tap a card to flip it
What will they ask next?
Learn it in depth
Last updated on 26 November 2026
Building an agent that has to use tools on real systems?
I design and build AI agents, the interface and the system behind it, with step limits, checked tool calls and logs. Book a short call and tell me what your agent needs to do.