The agent loop
See how an agent observes, decides, acts, receives results, and stops.
- 12 minutes
- intermediate
- Reviewed 2026-07-16
What is it?
An agent loop repeatedly gives a model current context, lets it choose an allowed action, records the result, and asks whether the goal is complete.
Why does it matter?
The loop enables flexible multi-step work, but every extra step adds cost, latency, and another opportunity for error.
The mental model
Observe → decide → act → inspect the result → continue or stop, inside a hard boundary.
A simple example
An agent reads an order, checks shipping policy, drafts a resolution, and stops before any account change.
What it is not
It is not unlimited autonomy or hidden reasoning that operators should simply trust.
Learn this first
These ideas make the lesson easier to place.
- Tool calling
- Workflow or agent?
Your first 60 minutes
Use one focused hour to make the idea concrete.
- Draw the loop and mark each stop condition.
- Set a maximum of three steps.
- Test tool failure, repeated action, and missing evidence.
Build this first
Build a simulated agent loop with two read-only tools, a maximum-step counter, and a human escalation result.
When not to use it
Use a fixed workflow when the sequence is known or when the loop cannot be observed, bounded, and interrupted.
What to learn next
Learn human approval and production tracing.