CourseLarge Language Models: The Complete Course · Module 6: Structured Outputs and Tool Use · part 45 of 103
Part 45 · Module 6: Structured Outputs and Tool Use

Lab: Typed triage, five tools and their guards

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

What you are building

SUPPORTDESK/ AFTER MODULE 6 schemas.py Triage, DraftReply parse, repair, salvage tools.py five fixed tools safe_execute guards.py scopes, pre-check audit, tool_loop tests/ 13 tests, no key hosted model two cells call it imports Module 1: llm.py (ask, llm) and data.py (records, decide)
Three new files (blue), checked by keyless tests (green), with the model (amber) reached only through them and Module 1's files (grey) underneath.

It is Friday 10 July 2026, the end of week 6. This week you made triage return a checked Triage, gave the model five tools and put code between the model and the billing system. All of it lives in notebook cells. This lab moves it into three files that Module 8's agent and MCP server will import. supportdesk/schemas.py holds Triage, DraftReply, the parser, the repair loop, salvage and one triage function that tries them in order. supportdesk/tools.py holds the five tools with their fixed names and the executor that never raises. supportdesk/guards.py holds the scopes, the pre-check on the records, the audit log and the loop that sets tool_choice each turn. Thirteen tests check it with no key. Two cells call the hosted model; everything else is offline.

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.