Module 04 · AI · The string and the contract · about 21 min to read
Continue where you left off ×
Structured Output and Tool Schemas · Open board
Building with LLMs. The board after “Context Engineering” (Context Engineering (what goes in the window, and who decides) ) decided what goes into the string the model reads. This one decides what happens to the string the model writes back.
Before you start. A model writes one token at a time, a token being a word or a piece of one, the unit it writes in. Everything it has read so far: instructions, conversation, and now a description of what it may ask for, sits in front of it as one long stretch of text, the prompt. This lesson follows what happens to the text it hands back.
The idea in 30 seconds
A model can only write text. It cannot read a database or press a button itself.
The form you hand it in advance, saying which boxes exist and what belongs in each, is the schema.
A slip that doesn’t parse: the wrong shape, a missing box, a sentence instead of a form, is a parse failure, and a grammar can make those nearly impossible.
A slip that parses can still be lying: the wrong order number, no actual yes from the customer. Catching that is validation, and it needs your own facts, not a bigger grammar.
When either check fails, the harness writes what’s wrong back as plain text and lets the model try again. Only after both pass does anything real happen.
Tool calling, function calling, structured output, JSON mode: different names for the same slip and the same clerk.
Read the story
Lesson 44 of 83 in AI
The rest of this lesson is part of a plan.
A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year .
See plans Already a member? Sign in
Or start free : a free account opens lessons 2 and 3 of every track.
In this lesson October 2022: a model that asks, in a sentence What broke: prose does not hold still June 2023: a form, not a sentence The returns desk: a slip, and someone who reads it Two different repairs, and only one can be guaranteed Where the forms sit, and what they cost How the form is written down Which way of asking actually works Four checks before the clerk acts How many forms fit on the counter All of it in code Terms it explains: schema, harness, parsing, parse failure, validation, mask, grammar, idempotent.
Review AI
Mark as read Saved in this browser, and to your account when you sign in.