Lesson 3 of 7
The agent loop
6 min read
You ask a normal chatbot a question, it answers, done. But what if the job takes ten steps, and step three changes the plan? That needs something that keeps going.
Give it a goal, not a script
An [agent](glossary://agent) is an AI you hand a goal instead of step-by-step instructions. To reach it, the agent runs a loop: think about the next move, act with a tool, observe what came back — then think again with that new information. It repeats until the goal is met.
The loop is the whole idea: an agent reacts to what it sees. When 7pm is booked, it doesn't give up — it observes, rethinks, and tries 8pm.
Why the loop matters
A single answer can't recover from a surprise. The loop can. Because the agent checks the result of each action before choosing the next, it can handle a booking that's full, a search that comes back empty, or a file that isn't there — routing around the problem the way a person would.
Looping is what makes an agent robust: it doesn't need a perfect plan up front, because it corrects course every time it observes.
A loop that can act on its own can also go wrong on its own. For anything that spends money or can't be undone, you'll want a checkpoint — which is exactly what the last lesson is about.
The shape of it
- —An agent takes a goal and works toward it, not a fixed script.
- —It loops: think → act → observe, over and over.
- —Checking each result lets it adjust when something doesn't go to plan.
You tell an agent "book a table for two Friday night." It finds 7pm is full. What does the loop do next?
Continue in the app
Take the whole Agents & Tools course — tracked
Get your personalized path, progress and streaks in the app — this lesson and every next one, in order.