Lesson 2: Let the model ask your code to act
20 min read·13 Oct 2026
Module 6 · Lesson 2 · About 50 minutes · Needs: Module 6 Lesson 1 (pydantic schemas); Module 5 Lesson 1 (the refund ruledecide); the guardaskfrom course-guide/02
The situation
It is Monday 6 July 2026, week 6. Triage now returns typed output, but the assistant still cannot look anything up. Ana Duarte's ticket T-1001 says she was charged 288 USD twice on invoice INV-2026-004512. To answer, the assistant must read the invoice, see the two charges and ask for a refund that Maya approves.
Tomasz has opened five functions for you: search_help_centre, get_workspace, get_invoice, issue_refund and escalate. This lesson gives them to the model, runs the loop that uses them, and makes sure a bad call never crashes it.