CourseLarge Language Models: The Complete Course · Module 8: Agents · part 59 of 103
Part 59 · Module 8: Agents

Lab: One traced refund agent, with every guard

46 min read·13 Oct 2026
Module 8 · Lab · About 80 minutes · Needs: lessons 1 to 4 of this module, and the Module 6 lab (or the cells in Step 1)

What you are building

SUPPORTDESK/ AFTER MODULE 8 hosted model two runs only agent.py one loop, 8 stops guards.py Module 6 chain approvals.py key, queue, Maya trace.py one line a step trajectory.py grades the path mcp_server.py: read-only lookups for other programs
One loop (blue) calls the model (amber) and Module 6's guards (grey); every refund waits in the approval queue (green), and every step is traced and graded.

It is Friday 24 July 2026, the end of week 8. This week each lesson wrote its own loop: run_agent with open_ticket in Lesson 1, a guarded run_agent with Budget in Lesson 2, run_loop in Lesson 3 and run_loop with a who label in Lesson 4. The repository gets one. supportdesk/agent.py holds the loop with all eight stop reasons, and it reaches the billing system only through Module 6's guarded_execute. supportdesk/approvals.py makes a refund request idempotent and puts a named person in front of every payout. supportdesk/trace.py writes one line per step, supportdesk/trajectory.py grades the path a run took, and supportdesk/mcp_server.py serves the read-only lookups over MCP. Two runs call the hosted model; everything else uses stand-ins.

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.