ReAct Pattern

You already built an agent loop: the model asks for a tool, your code runs it, you send the result back, and you call again.

People gave that cycle a name: ReActReason + Act.

This chapter does not teach a new loop. It names the three beats inside the one you know.


Three words

Word Plain meaning In your loop
Thought Decide what to do next The model’s plan (sometimes written as text; often hidden)
Action Do one concrete step A tool call (name + inputs)
Observation See what happened The tool result you send back

Then repeat until the model can give a final answer with no tool call.

Same loop. Clear names.
  person asks


  Thought  →  what do I need?


  Action   →  tool call


  Observation ← tool result

       └── if not done, think again


  final answer

One walk-through

Person: “What’s in notes.txt, and what time is it?”

Tools on the menu: read_file, get_time.

Beat What happens
Thought I need the file and the time.
Action Ask for read_file with path notes.txt
Observation "Milk, eggs, …"
Thought Still need the time.
Action Ask for get_time
Observation "2026-07-27 16:30"
Thought I have both. I can answer.
Final answer (no tool) — a short reply that uses both facts

Sometimes both tools are asked in one reply. That is still Action → Observation — just two actions in the same step. You already saw that under Multiple Tools.


Old style vs today’s APIs

Classic ReAct demos asked the model to write lines like:

Thought: I need the file.
Action: read_file(path="notes.txt")
Observation: ...

Your program had to parse that text. One wrong word and the loop broke.

Modern models use native tool calling:

Classic text ReAct Native tool calling (what you use)
Thought / Action written as prose Tool call is structured (name + inputs)
You scrape text with rules The API returns a clear tool call
Observation pasted into the prompt You send a tool result the API understands

The pattern is the same. The wire format got safer.

You still Reason → Act → Observe. The Action is a tool call. The Observation is the tool result.


Why the name helps

When something fails, ask which beat broke:

Symptom Often means…
Wrong tool Weak Thought / bad tool descriptions
Tool ran, answer still wrong Observation not used, or next Thought skipped a fact
Loop never ends No clear stop; raise the step limit only after you check the question

Naming the beats makes debugging easier than “the agent is weird.”


Words to keep

Word Meaning
ReAct Reason + Act: think, use a tool, see the result, repeat
Thought The decision about what to do next
Action The tool call
Observation The tool result fed back in
Final answer A reply with no tool call

See it in Code

The Code panel runs the same kind of tool loop you already know. It prints Thought / Action / Observation labels so you can see the pattern on each step.