The shared budget — sharing the context window.
The window holds far more than your question — and it all has to fit at once.
On the last page, the window held video frames, and the oldest one fell out when it filled up. A real conversation works the same way — except the window has to hold much more than just your latest question.
On every turn, four things share that one window: the instructions you gave the model at the start (its “system prompt”), the whole chat so far, your new message, and the space it needs to write a reply. All four have to fit together.
And the window never gets any bigger. A long chat simply fills it up. Once it's full, the oldest parts of the conversation are dropped to make room — just like those frames sliding off the screen.
Add a few turns and watch the window fill. Keep going, and you'll see the earliest turn get pushed out.
It's all one list — and it all costs tokens.
Every turn, you send the model the same kind of list: the system prompt, the history, and your new message. The whole thing must fit the window, with room kept for the reply.
messages = [
{"role": "system", "content": briefing}, # set once, sent every turn
*history, # every past turn — this keeps growing
{"role": "user", "content": new_message}, # your latest message
]
# the whole list must fit the window; trim the oldest history if it won't
reply = var.chat(messages, max_output_tokens=400) # reply space, reserved up front
One window, shared by everything.
The instructions, the whole chat so far, your new message, and the space for the reply all share one window. It never gets bigger — it just fills up, and the oldest turns drop out to make room.
So a big part of building with an LLM is choosing what to keep in the window — and what to drop, shorten, or look up only when you need it.