Lesson 21 of 30
The model has no memory between requests — every 'remembered' fact in a chat is really just still sitting in the history you resent it, which is why long conversations eventually become an engineering problem, not a modeling one.
11 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 3
A user mentions their name in message 2 of a chat. By message 20, the assistant still addresses them by name correctly. What's actually happening?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
An LLM API call is stateless. The model doesn't remember your last message, your last conversation, or that you talked to it five minutes ago — each request is evaluated fresh, with no memory of anything outside the text it's handed this time.
So how does a chat UI feel continuous? By cheating, in a completely standard way: the client keeps an ever-growing list of every message in the conversation (role: "user", role: "assistant", back and forth) and re-sends that whole list, or some processed version of it, on every single new turn. What looks like the model "remembering" you mentioned your name three messages ago is really just that message still being physically present in the array you sent this time. Delete it from the array, and the model has no name to recall — there's nothing else to forget it from.
This has two direct consequences that only show up once a conversation runs long:
Managing that growth deliberately is the actual engineering problem this lesson is about.
type Message = { role: "user" | "assistant" | "system"; content: string };
// Every turn appends to this — nothing here is "remembered" by the model,
// it's just resent as part of the request body.
let history: Message[] = [
{ role: "system", content: "You are a helpful tutor for this lesson." },
];
function sendTurn(userText: string) {
history.push({ role: "user", content: userText });
// ...call the model with `history`, get back an assistant message...
// history.push({ role: "assistant", content: reply });
// Naive: never prune. Eventually `history` exceeds the context window
// and every turn also costs more than the last one.
}
Two common, honest strategies for keeping this under control as a conversation grows:
"How would you handle a chat conversation that runs for hundreds of messages?" is a standard system-design-adjacent AI question, and naming the statelessness, the context-window ceiling, and a concrete pruning strategy (sliding window vs. summarization, with an honest tradeoff) is what separates a candidate who's actually built a chat feature from one who's only used one.