The model remembers nothing: your list does
The fake finds the name only if it is in the messages it receives, which is how a real model behaves too.
A chat is a list of messages, each with a role: system (rules), user (the person) and assistant (the model). The model remembers nothing between calls, so your program stores the list and sends all of it every time, trimming it when it grows too long.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 6 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write add_turn(history, user_text, reply_text) that appends a user and an assistant message to history and returns it.
Write last_user_message(messages) that returns the content of the newest user message, or None if there is none.
Explain it without notes
Why must an application re-send the conversation on every call?
What are the roles in a chat request and who writes each?
How would you stop a long conversation from overflowing the context window?
Expected output
fresh call: I do not know your name.
turn 1: Your name is Asha.
turn 2: Your name is Asha.
roles so far: user, assistant, user, assistant
forgetful app: I do not know your name. (sent only the last question)
lines in the model's input on turn 2: 3