07 · The runtime
The loop
One completion is a thought. An agent is a loop: think, act, observe, think again — until a stop condition fires.
In English
One model call is one thought. An agent is a loop: think, maybe use a tool, read what happened, think again — until it decides it is done, or you cut it off. Without a stop rule it will spend forever.
- Try this
- Click Step a few times. Notice the same model is called again with a longer transcript. Then hit the stop condition.
- Keep this
- An agent is a while-loop around a next-token engine.
Lab · the agent loop
Task: What is 15% of Tokyo’s population? Give a round number.
Step 1 / 7 · thought
I do not have a live census in weights I can trust. Search for Tokyo’s current population, then compute 15%.
- thoughtI do not have a live census in weights I can trust. Search for Tokyo’s current population, then compute 15%.
- toolweb_search
- observationTokyo prefecture ~14.0 million (2025 estimate). Greater metro ~37 million. Sources disagree on “Tokyo”.
- thoughtThe question is underspecified. Use the prefecture figure, flag the ambiguity, and compute 0.15 × 14,000,000.
- toolcalculator
- observation2100000
- answerAbout 2.1 million people, using Tokyo prefecture (~14M). The greater metro is ~37M, which would be ~5.6M — ask if you meant that.
ReAct, “agent,” “assistant with tools” — same skeleton. Model, inspect the output, maybe run a tool, append, repeat. Stop on a final answer, a step limit, a spend limit, or a human.
The loop is where most production bugs live: infinite tool calls, lost observations, no stop condition, a transcript that never gets compacted. Getting the while-loop right is unglamorous and decisive.