// Foundations · ~12 min

ReAct

Reach for it when: When the next step depends on what the last tool returned.

// 60-second mental model

How to hold it in your head

Think, use a tool, look at what came back, then decide again — until you can stop with an answer.

ReAct interleaves chain-of-thought (Reason) with tool calls (Act) and observations, looping until a stop condition.

// Mini architecture

Reason → Act → Observe → loop

┌──────────────┐
│ User goal    │
└──────┬───────┘
       ▼
┌──────────────┐   tool call    ┌────────────┐
│ Reason       │ ─────────────► │ Tool / MCP │
│ (next step?) │ ◄───────────── │  result    │
└──────┬───────┘   observe      └────────────┘
       │ done?
       ▼
┌──────────────┐
│ Final answer │
└──────────────┘

Each turn: decide → call at most one tool → read the observation → repeat or stop.

// Mini-project

Cited research agent (stub)

Claude Code + MCP web_search

Goal: Answer a factual question with 2–3 citations from search results — never from memory alone.

  1. Accept a research question.
  2. Reason: decide whether you need a search or can stop.
  3. Act: call a stub `web_search` MCP tool (return canned results in the stub).
  4. Observe: extract titles + URLs from the tool payload.
  5. Loop until you have enough sources or hit maxSteps.
  6. Stop: write the answer with inline citations.

Stub the MCP tool. Real search is optional later — the point is the loop and the stop condition.

// Common failure

What goes wrong

Symptom

Infinite tool loops / never stopping — the agent keeps searching “just in case”.

Fix

Hard maxSteps plus an explicit stop rule: “If I can cite ≥2 sources that answer the question, stop.”

// Self-reflection

Sit with this

When did you last ship a one-shot prompt that should have been ReAct?

Session only. Nothing is saved.