Tools: definition, schemas, and docstrings that work
Notebook· 02.01· 120–150 min· Lesson 19 of 129
The notebook opens in your lab, in a new tab. If your server is stopped, it starts first (a few seconds).
By the end you can
- Explain what a tool is to a model: a name, a description and a JSON Schema for the arguments. Nothing else is sent.
- Create tools with
@tool: type hints, docstrings (andparse_docstring=True), custom names and descriptions. - Define rich argument schemas with Pydantic (
Fielddescriptions,Literalenums, bounds) and see validation happen before your code runs. - Know the reserved argument names (
config,runtime) and what happens if you use them. - Choose a return value: string, object, or
content_and_artifact(data for your code that the model never sees). - Write descriptions that make the model pick the right tool, and avoid the
evaltrap in calculator tools. - Jupyter skill: check which kernel and Python a notebook really uses, and fix
ModuleNotFoundErrorfor good.
Before you start
Module 01 (models, messages, structured output). Lesson 00.02 environment.
