# 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.

- Page: https://tecyfy.com/concepts/react-pattern
- Subject: AI agents (https://tecyfy.com/concepts)
- Level: 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:

```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-thought](https://tecyfy.com/concepts/chain-of-thought) 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 use](https://tecyfy.com/concepts/tool-use) 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:

1. Send the conversation and the tools.
2. If the model asked for tools, run them and send back every result.
3. 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.

## Related

- [Agent](https://tecyfy.com/concepts/agent): A model that uses tools in a loop, deciding each next step from what the last one returned, until the task is done.
- [Tool Use](https://tecyfy.com/concepts/tool-use): Giving 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.
- [Chain of Thought](https://tecyfy.com/concepts/chain-of-thought): Having a model write out the steps of its reasoning before it gives an answer. Once a prompting trick, now built into "thinking" models.
- [Planner-Executor Pattern](https://tecyfy.com/concepts/plannerexecutor-pattern): An agent design that splits the work in 2. A planner writes the whole plan first, and an executor, which can be cheaper code or smaller models, carries out each step. The plan is changed only when a step fails.
- [Agentic Workflow](https://tecyfy.com/concepts/agentic-workflow): A fixed sequence of model calls and tools that your code controls, such as classify, then look up, then draft. An agent decides its own next steps; a workflow follows the path you wrote.

## Sources

- [ReAct: Synergizing Reasoning and Acting in Language Models](https://arxiv.org/abs/2210.03629)
- [Building effective agents](https://www.anthropic.com/engineering/building-effective-agents)
- [How tool use works](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview)
