Modern AI Engineering

Lesson 11.4 · 24 min · video lesson

ReAct Agents: Interleaving Reasoning and Acting

What happens if we make an agent write down its reasoning before every action, and read the result before its next thought?

In short: A ReAct agent (Reasoning + Acting) interleaves three kinds of lines: a Thought that reasons about what to do, an Action that calls a tool, and an Observation with the tool's result. The cycle repeats until the agent writes a Final Answer. Reasoning keeps actions purposeful, and observations keep reasoning grounded in real data, which reduces hallucination compared with reasoning alone.

What you will learn

  • What is a ReAct Agent
  • ReAct Agent vs AI Agent
  • Anatomy of a ReAct Agent
  • The ReAct Prompt Template
  • How a ReAct Agent Thinks and Acts
  • A Full Trace Example
  • Implementing a ReAct Agent
  • Common Failure Modes and How to Fix Them
  • Quick Summary

In this lesson

  1. What is a ReAct agent?
  2. Why interleave reasoning and acting?
  3. ReAct agent vs AI agent
  4. Anatomy of a ReAct agent
  5. The ReAct prompt template
  6. How a ReAct agent thinks and acts
  7. A full trace example
  8. Implementing a ReAct agent
  9. Common failure modes and how to fix them
  10. Worked example, step by step
  11. Practice: try it yourself

Key terms in this lesson

ReAct
An agent design that interleaves written reasoning (Thought) with tool use (Action) and results (Observation).
Thought
The model's short natural-language reasoning about what it knows and what to do next.
Observation
The tool's real output, appended to the transcript by the program, never by the model.
Scratchpad
The growing transcript of all previous Thought, Action and Observation lines sent to the model each step.
Stop sequence
A string that makes the model stop generating when it is produced, such as “Observation:”.
Multi-hop question
A question that needs several facts found in separate steps before it can be answered.

This lesson is part of the Generative AI Engineering and Complete AI Engineer tracks. See plans and pricing to open the full lesson, its video, labs and quiz, or try the free lesson first (free account needed).

← 11.3 The Agent Loop: Observe, Think, Act, Repeat · 11.5 Plan-and-Execute: Tackling Complex Tasks in Two Phases →