Part XVIII — LLM Agents, Tool Use, Planning & Multi-Agent Swarms · Chapter 2

The ReAct paradigm: Reasoning & Acting

Hook

Last chapter's tool call happened once: ask, call, get an exact answer back. What happens when the first thing a model believes is wrong — not about arithmetic, but about a fact needed to even know which tool to call next?

Intuition

Thought 1 I think Eiffel Tower is in Germany, so I need Germany's capital.

Action 1 look_up_location("Eiffel Tower")

Observation 1 France

Thought 2 Eiffel Tower is actually in France, not Germany. I need France's capital instead.

Action 2 look_up_capital("France")

Observation 2 Paris

Final answer: Paris

Switch landmarks. Every trace starts with a wrong guess about the country — Thought 1 is never corrected until Action 1 actually runs and Observation 1 comes back. Thought 2 only exists because Observation 1 contradicted Thought 1.

Formalize

ReAct — short for Reasoning and Acting — interleaves reasoning and acting in an explicit loop instead of answering in one shot:

ThoughttActiontObservationtThoughtt+1Final Answer\text{Thought}_t \to \text{Action}_t \to \text{Observation}_t \to \text{Thought}_{t+1} \to \cdots \to \text{Final Answer}
  • Thoughtt\text{Thought}_t — the model's reasoning at step tt, conditioned on every observation before it.
  • Actiont\text{Action}_t — the tool call or action the model takes at step tt.
  • Observationt\text{Observation}_t — the result that comes back from taking Actiont\text{Action}_t.
  • tt — the index of the current step in the loop.
  • Final Answer — the answer given once the loop stops.
  1. Each thought conditions on every prior observation

    That's the entire mechanism: Thoughtt+1\text{Thought}_{t+1} sees everything the loop has observed so far, not just the request it started from.

  2. A wrong initial belief isn't fatal

    The loop doesn't commit to an answer until an action has actually been taken and its result folded back in, so an early wrong thought still has a chance to be corrected before the final answer.

  3. Plain prompting has no way to self-correct

    Compare this to Part XIII's plain prompting: no action step exists there at all, so a wrong initial belief has no way to get corrected before the answer is given.

Play

Eiffel Tower: naive guess “Berlin” → corrected to “Paris” after observing Eiffel Tower is actually in France

Colosseum: naive guess “Athens” → corrected to “Rome” after observing Colosseum is actually in Italy

Statue of Liberty: naive guess “Paris” → corrected to “Washington, D.C.” after observing Statue of Liberty is actually in USA

Three landmarks, three plausible-sounding wrong guesses, three genuine corrections. None of the naive guesses were random — each one is the kind of association a model would plausibly make from training data (the Statue of Liberty was a gift from France) — which is exactly why the action-observation step matters: a plausible wrong belief is exactly the kind a model won't second-guess on its own.

Worked example

The full loop for "Eiffel Tower's capital":

  1. Thought 1 (wrong)

    "I think Eiffel Tower is in Germany, so I need Germany's capital." A plausible-sounding guess, not a random one — and wrong.

  2. Action 1 → Observation 1

    look_up_location("Eiffel Tower") returns "France" — directly contradicting Thought 1.

  3. Thought 2 → Action 2 → Final Answer

    "Eiffel Tower is actually in France, not Germany. I need France's capital instead." look_up_capital("France") returns "Paris" — the final answer, reached only because the loop didn't stop after the first (wrong) thought.

Checkpoint

Find the landmark, among the three, whose loop ends with the final answer Rome.

Pick a landmark to try it
Summary
ThoughttActiontObservationtThoughtt+1\text{Thought}_t \to \text{Action}_t \to \text{Observation}_t \to \text{Thought}_{t+1}

This chapter's loop always ran exactly two hops and always corrected exactly one wrong belief — real ReAct agents run until a stopping condition is met (the model itself decides it has enough information, or a max-step budget is hit), and a single loop can correct several wrong beliefs in sequence, or none at all if the first thought was already right. The next chapter asks a different question: before ever taking a single action, can a model break one large, ambiguous goal into an ordered list of small, unambiguous steps?