Module 07 · AI · On a real model · with code: Python · about 23 min to read
Continue where you left off ×
The Returns Desk, For Real (a real model, a real harness, and a dress rehearsal that fails)
The Harness · Open board
Building with LLMs. The board traces one turn of the returns desk through every box around the model. This lesson builds them in about four hundred lines of Python around a real model, then rehearses the desk until something breaks.
Before you start. The returns desk is a support assistant that can look an order up with lookup_order and open a return with start_return, on top of a model that only writes text (What the Model Sees (one string, every turn, from the top) ). A tool call is the model filling in a small form asking your code to run one of those (Structured Output and Tool Schemas (the contract between model and code) ). The harness is the ordinary code wrapped around the model (The Harness (everything around the loop that the model never touches) ). A loop cap is the most times the harness asks the model about one customer message before handing over to a person (The Loop (an agent is a while loop around one model call) ). The state machine is the six boxes a return moves through, IDENTIFY, VERIFY, ELIGIBLE?, CONFIRM, EXECUTE and DONE, plus ESCALATE for a person (Graphs and State Machines (when the shape of the task is known, draw it) ). A rung is one check a tool call must pass before it runs (Guardrails, Cost and Latency (the three budgets the harness enforces) ). An eval set is your own list of cases with a checkable answer beside each (Evals for Apps (the test suite for a program that is a string) ). An injection is text that tries to talk the model into something, like a fake “system note” in a message (Red-Teaming (breaking your own model before a customer does) ).
The idea in 30 seconds
End-state grading scores an agent by what the world looks like when it finishes, such as which returns exist, not by what it said on the way.
A headless call is a program calling a model with no chat window. Keep it in one function so the model behind it can be swapped.
A scripted conversation fixes every customer line in advance, so a changed result means the desk changed, not the customer.
A real model will make decisions you left open, such as whether to look an order up. The cure is code that checks the fact itself (here, looking the order up whenever the customer names one), not a better sentence in the prompt.
A flaky row passes on one run and fails the next with nothing changed. Pass^k counts only the cases that pass every one of k runs.
Read the story
Lesson 68 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 17 June 2024: τ-bench, a fake shop graded by its end state A headless call: a real model, from a Python script The build: two tools, six boxes, and rungs that never ask the model Sixteen scripted conversations: the dress rehearsal The first rehearsal: 13 of 16, and a desk that refused politely The re-run: 15, then 16, and a flaky row Can a plain script talk to a real model? One customer, then sixteen Why did the customer with order 5002 get stuck? Did the fix hold, and what does a customer cost? All of it in code Terms it explains: end-state grading, headless, scripted conversation, flaky, pass^k.
Review AI
Mark as read Saved in this browser, and to your account when you sign in.