Lesson 02.02 · Phase 02 · Tool Use & Function Calling
Tool schemas from first principles
The model never sees your function. It sees a name, a sentence, and a JSON Schema. Write those three well and most tool-calling bugs never happen.
Learning objectives
- Explain exactly what a model receives when you "give it a tool", and why the description matters as much as the code.
- Generate a JSON Schema from a typed Python function, including enums, optional arguments, defaults, and arrays.
- Validate the model's arguments against that schema before running anything, and return errors the model can fix.
- Emit the same tool in both OpenAI (function.parameters) and Anthropic (inputschema) formats.
You've shipped an LLM app. You add a searchflights tool, and within a day the logs show calls like these:
Loading the full lesson…