Course contentsShow
← AI Engineering
Lesson 640 of 1,88616. AI Agents - ImplementationFree lesson

ReAct Prompt Structure and Format

Understand the Thought-Action-Observation prompt template that drives ReAct agent behavior and tool selection.

ReAct Prompt Structure and Format

What you'll learn: How to structure prompts using the Thought-Action-Observation template that makes ReAct agents reason explicitly before taking actions.

The Core Template

ReAct agents work by breaking down their decision-making into three distinct, repeating steps within the prompt:

  1. Thought: The agent reasons about what to do next
  2. Action: The agent selects a tool and specifies arguments
  3. Observation: The system returns the result of that action

Think of it like talking yourself through a problem out loud: "I need to find the weather (Thought), so I'll call the weather API for New York (Action), and I see it's 72°F and sunny (Observation)."

The Structured Format

The prompt explicitly labels each step, making the reasoning chain visible:

Thought: I need to find the current population of Tokyo to answer the user's question.
Action: search["Tokyo population 2024"]
Observation: Tokyo has a population of approximately 14 million people.
Thought: I now have the information needed to answer.
Action: finish["Tokyo's population is approximately 14 million"]

This structure forces the LLM to:

  • Think before acting (reducing impulsive tool calls)
  • Explain its reasoning (improving debuggability)
  • React to observations (adjusting plans based on results)

Why This Format Works

By making reasoning explicit in the prompt itself, the LLM maintains a scratchpad of its own logic. Each Thought-Action-Observation cycle builds on the previous one, creating a transparent chain of decisions you can inspect and debug.

Key Takeaway: The ReAct prompt template structures agent behavior into explicit Thought-Action-Observation cycles, making the reasoning process visible and enabling the agent to adapt its plan based on tool results.