Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Prompting for Reasoning  ›  Capstone Project

ReAct — Reason, Act, Observe

ReAct Prompting 15 minReAct interleaves the model's reasoning with tool calls and their real results, so each next step is based on observed facts.

ReAct — Reason, Act, Observe

A customer asked, "Has order 4471 shipped, and when will it arrive?" Answering from the model alone produced a confident, invented delivery date. The shop's order system knows the real answer. The job is to let the model reason about what it needs, go and get it, and then reason from what it actually found.

The rule

Think, act, then look at the real result — and repeat.

ReAct (short for reason + act) interleaves three kinds of step:

  • Thought — the model reasons about what it knows and what it needs next.
  • Action — the model calls a tool with a specific input: search, database lookup, calculator.
  • Observation — the tool's real output is added to the context. The model did not write it; the system did.

The loop repeats until the model has enough to give a final answer. This is the basic pattern behind most AI agents.

Question: Has order 4471 shipped, and when will it arrive?
Thought: I need the order's current status.
Action: lookup_order(4471)
Observation: status=shipped; shipped_on=3 June; carrier_eta=6 June
Thought: I have both facts the customer asked for.
Answer: Yes — your order shipped on 3 June and should arrive around 6 June.

ReAct combines two earlier ideas. Like chain-of-thought, it reasons in steps. Like retrieval, it grounds the answer in real data. And because the observation comes from a real system, the model's next thought responds to facts rather than its own guesses, which cuts hallucination sharply.

In a real application, a program sits in the loop: when the model writes an action, the program pauses generation, runs the tool, pastes the result in as the observation, and lets the model continue. Modern APIs support this directly through tool calling, where the model emits a structured request instead of plain text.

The shortcut

Before answering, ask of every fact the reply needs: "Can a tool tell me this?" If yes, that is an action, not a guess.

A two-action ReAct loopStep 1 of 4
  1. Thought

    The customer asks if a repair on bike B-208 is done and what it costs. I need its status and the bill.

The trap: letting the model write its own "Observation" lines. A model that invents observations is back to hallucinating, just in a tidier format. Observations must come from the real tool, and tools with side effects still need the permission limits from the prompt-injection lesson.

Drills

Answer fast — trust the rule.

quick drill

In ReAct, where does an Observation come from?

quick drill

What is the correct order of one ReAct cycle?

quick drill

A customer asks the price of part 88213. What should a ReAct agent do first?

quick drill

Which ReAct setup is broken?

Remember

  • Think, act, then look at the real result — and repeat.
  • Shortcut: every fact a tool can provide is an action, not a guess.
  • Trap: model-written observations — they must come from the real tool.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainWrite the loop

A customer asks, 'Is my order 4471 shipped yet, and when will it arrive?' Write a short ReAct trace with Thought, Action and Observation lines using an order-lookup tool, and explain why it is better than answering from the model alone.