The Agent Loop
Think, act, observe, repeat.
A single tool call answers a single question. But many real tasks need many steps, and the next step depends on the last result. An agent is a model, that works in a loop, planning, acting, and checking, until the job is done. In this lesson, you will see how.

- Many steps, not one
- A model that works in a loop
- Until the job is done
The agent loop
Here is the loop. The agent first thinks, what should I do next, to reach the goal? Then it acts, by calling a tool. Then it observes, reading the result. Then it decides, is the goal reached? If not, it thinks again, using what it just learned. Think, act, observe, repeat. The loop ends, when the agent decides the goal is complete, or it hits a safety limit.
- Thinkwhat should I do next?
- Actcall a tool
- Observeread the result
- Decidedone, or loop again
An agent at work: planning a trip
Imagine asking an agent, find me a cheap flight to Rome next month, and a hotel near the centre. It might search flights, and see three options. It compares prices, then picks the best. It searches hotels near the centre, and checks reviews. It sees that one is full, and tries another. Finally, it reports its findings, and asks for your approval, before booking. Each step depended on the last.
Workflow or agent?
Not every job needs an agent. A workflow follows steps that you wrote in advance, so it is predictable, cheap, and easy to test. An agent decides its own steps, so it is flexible, but harder to predict, slower, and more expensive. The wise rule is, use the simplest thing that works. If you know the steps, build a workflow. Use an agent only when the path truly cannot be known in advance.
Workflow
- Fixed steps you design
- Predictable and cheap
- Easy to test
- Best when steps are known
Agent
- Model chooses the steps
- Flexible, handles surprises
- Harder to predict
- Best when the path is unknown
Summary
Excellent. An agent works in a loop, think, act, observe, and decide, using tools along the way. Use a workflow when the steps are known, and an agent when they are not. Next, how agents plan, remember, and stay safe.
Key takeaways- Agent loop: think, act, observe, decide
- Workflow: fixed steps. Agent: flexible steps
- Use the simplest thing that works