Lesson 03.03 · Phase 03 · The Agent Loop

Stop conditions & max steps

Every run ends for a reason. Name each reason, give each one its own stop, and never end on "the budget ran out" without asking for a best answer.

Learning objectives

  • List the ways an agent run can end, and give each one a distinct, testable stop reason.
  • Implement a stop policy with a step budget, a time budget, repeated-call detection and an error-streak limit.
  • Compare two ways of finishing, "no tool calls means done" and an explicit finish tool, and know what each gets wrong.
  • Measure whether an answer is grounded in tool results, not just whether it's correct.

Lesson 1's loop had two endings: the model replies without tool calls (done), or maxsteps runs out (give up, with an empty answer). Real runs end in more ways than that:

Loading the full lesson…