Read the calendar: the first tool
The assistant reads your calendar for the first time. The model cannot run any code, so you hand it a function, list_events: the model asks for it, Pydantic AI checks the arguments and runs your function, and the result goes back in a second request before the model writes the reply. Eight stops follow one real question, "What's on my calendar tomorrow?": the new code in bot.py (under 40 lines) → function_schema turns the signature and docstring into what the model sees → the first request carries two tools → Gemini answers with a function call, list_events(2026-11-27, 2026-11-27) → the arguments are checked, then your function is awaited: download the calendar, expand the weekly meeting → the result becomes a ToolReturnPart and rides the arrow back to ModelRequestNode → the second request carries 3 messages and Gemini calls final_result → tomorrow's four events on your phone. Then a staged run with a stand-in model sends start as "tomorrow": the validator sends it back before your function runs. The calendar is read from its secret iCal address, no OAuth.
Source code shown in the videos is quoted from pydantic/pydantic-ai (MIT licence), pinned at v2.71.0. This course is not affiliated with or endorsed by Pydantic; the explanations and assignments are original. Course code and assignments · pydantic/pydantic-ai at v2.71.0 · License