Lesson 2 of 30
A model's context window is one shared token budget for the whole request — system prompt, history, retrieved documents, the new message, and the response all have to fit in it together.
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 chat request includes a system prompt, a long conversation history, a retrieved document, and the new user message. How is the model's context window shared across these?
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
The context window is the maximum number of tokens a model can process in a single request, counting everything: the system prompt, the entire conversation history you send back with each turn, any documents or retrieved snippets you've stuffed in for grounding, the user's new message, and the model's own response. It's one pool, not separate allowances for each piece.
That last part is the part people miss. There's no dedicated "history budget" and "response budget" — every category is drawing from the same total. A long conversation history leaves less room for the response. A large retrieved document leaves less room for both.
When a request would exceed the window, one of two things happens, and which one depends entirely on how the calling application is built, not on the model itself:
The model itself doesn't "decide" to truncate anything — it never sees the token count. That logic lives in whatever code assembles the request before it goes out, which means it's the application developer's responsibility to manage, not something the API handles for free.
// A simplified view of what lib/ai/chat/handler.ts has to reason about
// before every request goes out
const request = {
systemPrompt, // persistent instructions — fixed cost, every turn
history: messages, // grows with every back-and-forth in the conversation
retrievedContext, // documents pulled in for grounding, if any
newMessage, // the user's latest turn
};
// all four of the above, PLUS the model's response, share one token budget
A fixed-size window: the model's total token budget for this one request.
A chat feature that just appends every past message to history forever will eventually hit this wall. The fix isn't "use a model with a bigger window" as a default reflex — it's deciding, deliberately, what actually needs to stay in context: maybe a running summary of older turns instead of the full transcript, maybe only the most relevant retrieved chunks instead of every document that matched a search.
"A user's conversation is getting long and responses start failing — what's happening and how do you fix it?" is a direct test of whether a candidate understands the context window as one shared budget, versus assuming the platform just handles unlimited history for free.