What you add
The diary is a plain Python class,Salon, in salon/store.py. It keeps customers and bookings in memory. Copy the file from the example. You do not write it here.
Each method is typed, and each argument says what it means. Each answer has a
Pydantic model too. This is the shape of find_slots and its answer, Diary.
salon/store.py
local_tool reads the types and the descriptions and builds the tool schema. A ToolRegistry holds the tools of one agent.
salon/agent.py
outputnames the answer’s model. The method returns a dict, so it names the model here. A method that returns aDiaryneeds nooutput=. Every answer is checked against it, and an answer of the wrong shape fails the call.lockedfillscustomer_phonefrom the call state. The model never sees that argument, so it cannot invent a number. While no number is saved, the call is refused with a hint.announceis a line the agent says as the tool starts. A refused call says nothing.
Try it
Start the agent as before.- “I’d like a haircut on Friday.” Robin has no number yet, so the tool is refused. Robin should ask for your number.
- Give a number with its country code. Then say “Friday” again.
- You should hear “Let me have a look.” Then Robin should read out free times from the diary.
Why it works this way
The model fills tool arguments from what it heard. It can mishear or invent a value. So the library checks every call against the schema before your code runs, and a bad one goes back to the model with what to fix. A value the caller never chooses, like the number of the person on the line, comes from the state instead. And a slow tool is not silence, because the announce line plays first.What you have now
Next: Book step by step
Turn booking into a task, so Robin confirms before it writes.