An agent is a loop
In the last lesson the model was a pure function — one call, text in, text out. That's enough to answer a question but not to get something done. Say the goal is "move from position 0 to position 5." A single function call can't do that: it returns one suggestion, then forgets everything. To make progress you have to call it again, tell it where you ended up, and let it suggest the next move — again and again until you arrive. That repetition is the whole difference between a model and an agent.
The shape of the repetition is the agent loop: perceive the world, decide
an action, act on it, observe the result, repeat. Crucially the split is
the model proposes, your runtime disposes. The brain (decide) only ever returns
a word like "step" or "stop" — it never touches the world directly. Your code
(act) is what actually changes position. That separation is what keeps an agent
governable: the model can suggest anything, but only your runtime can execute it.
Trace one pass. perceive reports {position: 0, goal: 5}; decide sees 0 < 5 and
returns "step"; act bumps position to 1; the loop comes around and perceives 1.
Five "step" decisions later position is 5, decide returns "stop", and the loop
breaks. No single call did the work — the loop did.
Below, the environment and the perceive / act steps are written for you; the
brain is missing. Implement decide(obs) so it returns "step" while position is
below goal and "stop" once it arrives. "Done" is the agent walking 0→5 and halting
exactly on arrival.
The loop is the whole idea. Everything else in this academy — tools, memory, planning, stop conditions — is something you add inside this loop.