Skip to main content
AI Agents & Automation

⏱ About 15 min15 XP

The ReAct Pattern

Imagine a detective who writes in a notebook before every move. Before interviewing a witness, they jot down what they hope to learn and why. After the interview, they write what they found out. Before searching the crime scene, they note their theory. After searching, they record what they discovered. This back-and-forth between writing and doing — reasoning, then acting, then reasoning again about the result, then acting again — is the detective's method. It is also the heart of the ReAct pattern.

What ReAct Stands For

ReAct is a pattern introduced by AI researchers in 2022 as a way to structure how language-model agents handle multi-step tasks. The name combines two words: Reasoning and Acting. In the ReAct pattern, an agent alternates between two distinct move types on every turn. Thought: a reasoning step in which the agent thinks out loud about the current situation, what it knows, what it needs to find out, and what to do next. This thought is not an action — it is internal reasoning made visible. Action: a specific operation the agent performs — calling a tool, producing output, or making a decision — based on the thought that immediately preceded it. After the action, the environment returns an observation. That observation triggers a new thought, which triggers a new action — and the cycle continues until the task is complete.

ReAct — Reasoning + Acting

ReAct is a pattern where an agent alternates Thought steps (explicit reasoning) with Action steps (tool calls or outputs), using the observation from each action to inform the next thought. Thought → Action → Observation → Thought → Action → ...

A ReAct Loop in Action

Here is a simplified ReAct sequence for the task 'What was the most-watched TV show in the US in 2023?' Thought 1: I do not have reliable memory of 2023 TV ratings. I need an external source to answer this accurately. I will search for it. Action 1: search('most-watched TV show US 2023') Observation 1: Results show multiple sources citing a specific popular drama series as number one in total viewers. Thought 2: Multiple sources agree on the same show, which increases my confidence. I also notice the figure refers to live-plus-same-day ratings — I should note this qualifier in my answer. Action 2: produce_answer('According to live-plus-same-day Nielsen ratings, the most-watched show in the US in 2023 was...') Each Thought explains the reasoning before the Action. Each Observation informs the next Thought. Nothing happens without a reason, and every reason is recorded.

Why the Thought Step Matters

Logging the Thought before every Action creates a transparent audit trail. Developers can read the trace and understand exactly why the agent did what it did — and spot where reasoning went wrong if results are incorrect.

ReAct vs. The Basic Agent Loop

ReAct is not a replacement for the basic Perceive-Think-Act-Observe loop — it is a specific, structured implementation of it. The basic loop describes the general cycle that all agents follow. ReAct specifies exactly how that loop works for language-model agents: by making every Think stage a written Thought and ensuring every Act is justified by the Thought that preceded it. This structure has made ReAct one of the most widely adopted patterns in production AI agent systems. Frameworks like LangChain, AutoGen, and OpenAI's function-calling interface all implement variations of the ReAct pattern because it produces agents that are more accurate, more debuggable, and more trustworthy than agents that act without explicit reasoning.

Match each ReAct component to its role in the loop.

Terms

Thought
Action
Observation
Trace

Definitions

The full recorded sequence of thought-action-observation turns for a completed task
The tool call or output the agent executes based on the preceding thought
The result returned by the environment after the action, which feeds the next thought
The agent's explicit written reasoning about the current situation before taking any action

Drag terms onto their definitions, or click a term then click a definition to match.

In the ReAct pattern, what must happen immediately before every Action?

Which of the following is a correct ReAct sequence?

Write a ReAct Trace

  1. Step 1: Your agent receives this task: 'My birthday is in 3 days. Suggest a restaurant for dinner near downtown Chicago and tell me if it has vegetarian options.'
  2. Step 2: Write a full ReAct trace — at least three full Thought-Action-Observation turns. Label each step clearly as Thought, Action, or Observation.
  3. Step 3: Make each Thought at least two sentences long, explaining what the agent currently knows and why it is choosing the next action.
  4. Step 4: Invent plausible Observations for each Action (you do not need a real search engine — just write realistic results).
  5. Step 5: What is the final Action that ends the loop? Write it out in full.
  6. Step 6: Look at your trace and identify: at which Thought step was the reasoning most important? Why?