What is the ReAct pattern for AI agents, and how does it relate to tool calling today?
An agent design where the model alternates between reasoning about what to do next and taking an action, such as a tool call, then reads the result before deciding again. Most agent loops today follow it.
intermediate · Also called ReAct, Reason and Act, Thought, Action, Observation, Agent Loop
ReAct, short for "reason and act", is the idea behind almost every AI agent: think about the next step, take it, look at what happened, and think again. It was described in a 2022 paper from Princeton University and Google, which had a model write its steps as text:
Thought: The customer gave order KX-48213. I need its status before I answer.
Action: find_order[KX-48213]
Observation: shipped on 14 October, not yet delivered
Thought: It is on its way. I can tell them, and say a person will confirm the date.
Code read each Action line, ran it, wrote the result back as the Observation, and asked the model to continue.
Why the 2 halves need each other
Reasoning alone, as in chain-of-thoughtChain of ThoughtHaving a model write out the steps of its reasoning before it gives an answer. Once a prompting trick, now built into "thinking" models. prompting, lets a model plan but leaves it working from memory, so one wrong fact carries through every later step. Acting alone, calling tools with no reasoning in between, gets facts but loses track of the plan. The paper found the mix did better on both counts: checking facts through a simple Wikipedia API cut the made-up answers of chain-of-thought, and on 2 benchmarks of interactive decision making, ALFWorld and WebShop, ReAct beat the methods trained by imitation and reinforcement learning by 34 and 10 percentage points, from just 1 or 2 examples in the prompt.
ReAct today
The text format has gone, and the loop has stayed. Model APIs now have tool useTool UseGiving a model a list of things it can ask to have done, such as search the web or read a file. The model asks; the program around it does the work and hands back the result. built in: the model returns a structured tool call instead of an Action: line, the API's stop reason says it is waiting for a result, and your code sends the result back as a message. Models with built-in thinking do the "Thought" part on their own before each call. What is left for you to write is the loop itself:
- Send the conversation and the tools.
- If the model asked for tools, run them and send back every result.
- Repeat until it answers, or until a limit is reached.
The limit matters. A model that misreads a result can call the same tool forever, and every turn resends the whole conversation, so a stuck loop gets more expensive with each step. Anthropic's guidance on agents is to set a maximum number of iterations as a stopping condition. When it is reached, hand the task to a person.
Sources