CourseAgentic AI Engineer: The Complete Course · Module 5: The Agent Loop · part 29 of 97
Part 29 · Module 5: The Agent Loop

Lesson 1: The agent loop, written by hand

30 min read·
Module 5 · Lesson 1 · About 60 minutes · Needs: Module 3 (make_failure_safe_tools, call) and Module 2's output contract (OUTCOME: <label>)

The situation

It is Monday 11 May 2026, week 5. The eight tools are served over MCP, and Priya asks: "So who calls them?" So far you have run one model turn at a time. The first unattended run of the test queue is on Wednesday 20 May, and it needs a loop: code that asks the model what to do, does it, shows it the result, and asks again.

Marta adds a condition: "Every run stops. I want to know why, and what it cost." You trace R-1004 all lesson: Mei Tanaka cancelling order 8204, the SoundPod headphones, $79.00, still processing.

The rest of this course is yours to keep

This course is bought on its own, once, and stays readable afterwards, including the parts added to it later.

Or open everything with a plan