6.2.2 · D1AI Agents & Tool Use

Foundations — ReAct (reasoning + acting) framework

2,506 words11 min readBack to topic

Before you can read the parent note, you need to be fluent in every squiggle it uses. This page builds each one from nothing, in the order that each depends on the last. If you have never seen , , or before — perfect, that is who this page is written for.


0. What a "language model" even is

The key thing to hold onto: a language model does not return one fixed answer. It returns a spread of possibilities, each with a chance attached. That spread is what the symbols in the next sections describe.

Figure — ReAct (reasoning + acting) framework

Look at the figure. The orange bars are the model's guesses for what word comes next after "The Eiffel Tower is in ___". Each bar has a height = how likely the model thinks that word is. Tall bar = confident. That height is a probability, our next symbol.

You will use this idea everywhere in the parent note and in Tool Use in LLMs.


1. Probability — the symbol

Why does ReAct need this? Because the model is a guesser, not an oracle. When the parent writes

it is saying: "the model's chance of producing each possible thought, given the question and some examples." We are about to unpack that vertical bar .


2. The conditioning bar — the symbol

So reads left-to-right as:

chance of a thoughtgiven the question and some example demonstrations.

The comma just means "and": "given and examples."


3. The question, the answer, and the tools — , ,

The agent's job: pick tools out of this box, in a smart order, to turn into . This is exactly the theme of Agent Architectures.


4. The three moving parts — Thought, Action, Observation

Figure — ReAct (reasoning + acting) framework

The figure shows one full turn of the loop as three coloured boxes. Blue = the model thinks, orange = it acts on a tool, green = the world observes back. The green arrow curls back up to a new blue box — that curl is ReAct. Everything else on this page is machinery for writing that curl down in symbols.

Why three parts and not two? The parent's whole argument is that pure thinking (blue only) can't touch the real world, and pure acting (orange only) can't correct itself. You need the green observation to close the loop.


5. Sampling — the symbol

means: the first thought is pulled at random from the model's spread of possible thoughts, weighted by how likely each is, given the question. It is not "equals" — the model could produce different thoughts on different runs, and that randomness is why Self-Consistency (running many times) even helps.


6. Picking the best action — the symbol

The parent chooses an action with:

Let's earn every piece.

Figure — ReAct (reasoning + acting) framework

Read the figure left-to-right. Each tool in gets a bar = how likely the model thinks that tool is the right next move. points at the tallest bar's height. points at the tool underneath it (here, Search) — and that tool is what we actually run. Putting it together:

= the tool (from the box) that the model rates as most likely to be right, given the question and its first thought.

Why and not sampling () here? Because for actions we usually want the single best move, not a random one — a wrong tool call wastes a step. (Some systems sample actions too; the parent picks the confident-best version.)


7. Running the tool — the symbol


8. The trajectory — the symbol


9. Stopping — the action


10. Multiplying chances — the symbols and

The parent's big formula is

Two new symbols.

Figure — ReAct (reasoning + acting) framework

The figure shows two trajectories. The top one ends on the correct , so its indicator is and its whole probability survives. The bottom one ends wrong, so the indicator zeroes it out (grey). "Maximise over " then means: find the run that is both likely and correct.


Prerequisite map

Language model as next-word guesser

Probability P and the given bar

Question Q, answer A, toolbox T

Thought, Action, Observation triple

Sampling with tilde

argmax and in-set membership

Execute a tool for observations

Trajectory tau and past slice

Trajectory probability with product Pi

ReAct objective with indicator

ReAct loop: think act observe repeat

Related deeper topics once you're fluent here: Reflexion (adding self-critique to the loop), MRKL (routing questions to tools), and Self-Consistency (sampling many trajectories).


Equipment checklist

Cover the right side and see if you can answer each before revealing.

What does mean in words?
The chance of , given that we already know (the bar = "given").
What does the tilde in tell you?
The thought was randomly sampled from that spread of chances — it is not equal to a number.
Difference between and ?
= the biggest value; = the input/thing that produces that biggest value.
What does say?
Action belongs to the toolbox .
What is a trajectory ?
The full ordered history of every (Thought, Action, Observation) triple in the run.
What does pick out?
All steps before step — the past breadcrumbs.
What does do, and why multiply?
Multiplies each step's chance together, because the whole run needs step 1 and step 2 and … to all happen.
What is ?
An on/off switch: if the trajectory reached the true answer , else .
Which factor in the step formula is deterministic, and why?
— running the same tool call always returns the same observation.
Why must every run reach ?
It is the stop signal; without it the think–act–observe loop never ends.