Lesson 3.2

Building an agent loop

An agent is a loop: call the model, run the tool it asked for, feed the result back, repeat. Every loop needs a stopping condition it cannot argue with.

Duration
16m
Level
Intermediate
Students
17k students

Overview

An agent is a loop: call the model, run the tool it asked for, feed the result back, repeat. Every loop needs a stopping condition it cannot argue with.

In this lesson you will:

  • Structure the call, execute, feed back cycle
  • Bound the loop with iteration and token limits
  • Log each step so failures can be replayed

Resources

Claude API documentation

The official reference for the tools used in this lesson.