AssayAssay
01 / 08

Lesson 01 · Mechanics · 10 min

What a loop is

A single model call takes a question and returns text. It cannot look anything up, so when it is asked about something it has no access to, it has two options: say it does not know, or invent an answer. Models are trained to be helpful, so they frequently invent.

An agent loop changes the shape of the interaction. Instead of one call, the model is called repeatedly, and on each call it may either finish or ask for something. When it asks, the caller runs the request, feeds the result back, and calls again. That repetition is the entire mechanism.

The agent loopmodeldecidestool callname + argsobservationthe resultanswerno tool askedactrun itobserveor finishwithout a budget or a repeat-check, this cycle has no reason to stop
One iteration is a model call plus whatever tool it asked for. The loop ends when the model replies without requesting a tool — or when your code stops it.
IterationOne pass through the loop: a model call, and whatever tool it asked for.
ToolA function the model may request by name and arguments. The model never runs it; your code does, and returns the result.
TrajectoryThe ordered sequence of iterations and observations that led to an answer.

The lab beside this lesson runs the same task two ways. "No loop" sends one call with no tools, so the model answers from nothing. Any specific detail in that answer — a status, a date, a carrier — was invented, because the information was never available to it. "ReAct" gives it tools and lets it iterate.

Watch what ReAct does not fix, though. Giving the model tools makes grounding possible; it does not guarantee it. A model can call the lookup, read a status and a placed date, and still promise a delivery window the tool never returned — the fact that a tool ran is not the same as the answer using only what it returned. The lab runs a small grounding check on the reply and flags exactly this: a delivery estimate or a shipping date the observations never contained.

During development of this course, one model answered "Order 88213 is currently in the Processing state" without calling a single tool. That order exists, and it was delivered. Confident, specific, and entirely fabricated — which is the cleanest argument for loops there is.

Checkpoint

Run one task with no loop and then with ReAct, and identify a detail the first answer invented.

“Where is my order 41902? It hasn't arrived yet.”

The shortest useful loop: one tool, one answer. A model that replies without calling anything is inventing the status.

Start with "No loop" on the simple lookup task. Read the answer, then check it against what the tools actually return by switching to ReAct and running again.

Nothing has run yet. Pick a task and press Run — every iteration appears below.