The Model Has Amnesia
Message History
Part of: Build a Chatbot
When you first call an LLM, the model forgets everything the instant it finishes replying. You send "My name is Sam." It says "Nice to meet you, Sam." You send "What's my name?" and it cannot answer. The model has no record of what you told it a moment ago. What message history is Each API call is a fresh start. The model didn't store your name anywhere; it can't. There's no database behind the scenes remembering you. The model is stateless : it keeps nothing between calls. So a chatbot that remembers is an illusion you build. The tool you build it with is message history : the running list of everything said so far, which you resend on every call. The model re-reads the whole thing each turn and answers as if it remembered. The "memory" is just a Python list you keep adding to. How it works The Messages API takes a list. Each item is a dict with two keys, a role and content: The role labels who said it: user for the human, assistant for the model. Roles alternate (user, assistant, user, assistant), and the list must start with a user turn. A working chatbot is four steps in a loop: 1. Read what the user typed. 2. Append it as a user turn. 3. Call the API with the whole list , not
Challenge: Replay the Whiteboard