Learn · narrated lesson · about 4 minutes

When does it stop?

An AI agent works on its own, step after step. Watch one fix a bug, and find out what really ends the loop.

Transcript

This invoice should say nine hundred rupees.

It says eight hundred and ten: the billing software applies the discount twice.

Two of its sixteen automatic checks fail.

You ask an AI agent to fix it, and it works on its own, step after step.

So when does it stop?

Take a guess, and tap how sure you are. We'll come back to it.

That agent is really two parts.

In the glass room sits Claude. It reads what it's given, and writes back.

It has no hands: it can't open a file, or run anything.

Everything passes through this slot, like the tray under a bank counter's glass.

Outside sits the harness, the program around Claude. Here, that's Claude Code.

It has the hands, and the tools.

So: Claude asks. The harness does.

Your request goes into a ledger: the conversation so far.

Each round, the harness slides the whole ledger through the slot.

Claude keeps no memory between rounds.

So every time, it reads the ledger from the top.

Claude wants to read the checks, but can't. So it writes a request.

Amber means asking.

Its name is tool use: which tool, on what, and a ticket number.

The whole reply comes out with one stamp, the stop reason: why Claude stopped writing.

This one says tool use. Meaning: I need something done.

The harness reads the stamp, and opens the file. Not Claude.

It writes back what it found. Teal means coming back.

Its name is tool result, with the same ticket number.

It's filed as a user message, even though the harness wrote it.

Then the whole ledger goes back in.

That's one lap: ask, stamp, do, report.

Lap two. Claude writes: Found it. The discount is applied twice. I'll fix line twelve.

It has words. It sounds finished.

Your call: stop, or loop?

The stamp says tool use.

Claude wrote words and asked for a tool, in the same reply.

A harness that stops on words would quit right here, with the invoice still wrong.

So that rule, stop when you see words, gets wiped.

Words never decide. The stamp does.

Tool use: go round again. End turn: finished.

Edit line twelve.

Run the checks.

Sixteen of sixteen pass.

Claude writes: Fixed it. The discount was applied twice, and all sixteen checks pass.

End turn.

Claude is finished, and asks for nothing more.

So the harness stops, and hands you the answer.

One more control on the desk: a turn limit, a cap on how many laps.

It's a circuit breaker for a loop that runs away.

If it trips, the run is cut off before Claude says it's done.

A backstop. Never the finish line.

So, back to your guess: when does it stop?

Not when Claude writes words.

Not when a limit trips: that only cuts it off.

It stops when the stamp, the stop reason, says end turn.

Claude asks. The harness does. The stamp decides.

Now, three quick cards from memory. Then you play the harness.

Check yourself

Where the picture is simplified

Detailed exam version of this lesson