← Advanced learning mapadvanced lesson · act

The agent loop

See how an agent observes, decides, acts, receives results, and stops.

  • 12 minutes
  • intermediate
  • Reviewed 2026-07-16
01

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.

02

Why does it matter?

The loop enables flexible multi-step work, but every extra step adds cost, latency, and another opportunity for error.

03

The mental model

Observe → decide → act → inspect the result → continue or stop, inside a hard boundary.

04

A simple example

An agent reads an order, checks shipping policy, drafts a resolution, and stops before any account change.

05

What it is not

It is not unlimited autonomy or hidden reasoning that operators should simply trust.

06

Learn this first

These ideas make the lesson easier to place.

  • Tool calling
  • Workflow or agent?
07

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.
08

Build this first

Build a simulated agent loop with two read-only tools, a maximum-step counter, and a human escalation result.

09

When not to use it

Use a fixed workflow when the sequence is known or when the loop cannot be observed, bounded, and interrupted.

10

What to learn next

Learn human approval and production tracing.