Skip to main content
NewEpisode 3a is out: Carry the conversation onWatch →

Free with an account

This part is free. Sign in or create an account to watch it.

Sign up
Conversation · 3a

Carry the conversation on

The model remembers nothing between requests. The opener is the follow-up from 1b: first "Remind me to call the dentist tomorrow at 3pm", then "Make it 4pm instead." The bot from the end of 2c has tools now, so it goes through your email, your calendar and the web looking for what "it" could be: in the recording the answer came after 326 seconds (one request got no answer for two minutes and the run was started again; the run that answered took 9 requests and 154 seconds) and was a chat reply, with no reminder moved. Then the whole mechanism: the bot keeps one list of messages per chat, hands the whole list to every run (message_history=), and stores the longer list the run gives back (all_messages()). Six stops follow the second message: our five lines → the run takes a copy → UserPromptNode turns the new message into a request → ModelRequestNode stamps it with the run and conversation ids and sends all four contents to Google (561 → 937 input tokens) → the model answers and CallToolsNode appends a closing result → we store six. With the list: 1 request, 4 seconds, and the reminder moves to four. Then five messages about the calendar: tool calls and their results are in the list too, so later follow-ups need no calendar read (8 requests against 27), and the price is that each request is bigger than the last (556 → 2,654 input tokens). Last, two things: why the list holds 14 and not 15 (two requests in a row are merged, so use new_messages()), and that earlier messages reach the model with no time on them.

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