Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
How LLMs Read and Charge  ›  Lesson

Context Windows — The Model's Desk

Context Windows 12 minThe context window is the fixed-size bundle of tokens a model can see in one call, including instructions, tools, history, tool results and its own answer.

Context Windows — The Model's Desk

Asha has been chatting with Tripmate for an hour: three trips, dozens of train searches, a long list of hotel options. Suddenly Tripmate "forgets" that she is vegetarian, which she said at the very start. Nothing broke. The conversation simply outgrew the model's context window.

The rule

The context window is everything the model can see at once — nothing more.

A model has no memory between calls. Each time you call it, you send a bundle of tokens, and it answers using only that bundle. The context window is the maximum size of that bundle, measured in tokens. It must hold:

  • the system instructions ("You are Tripmate, a travel assistant…"),
  • the tool descriptions the agent may use,
  • the conversation so far, including tool results,
  • and the answer the model is about to write — output tokens share the same window.
[ instructions | tools | chat history | tool results | → answer ]
 └──────────────────── must fit in the window ────────────────────┘

Window sizes vary a lot between models and keep growing, but every window has an edge. When the bundle would overflow, something must go: the application trims, summarises or drops older material, or the call fails. Even inside a big window, models tend to use details in a very long context less reliably than details that are short and clearly placed, so "it fits" is not the same as "it will be noticed". Every token in the window is also paid for on every call, which the next lesson turns into numbers.

The shortcut

Think of the window as a desk. Anything not on the desk does not exist for the model. Before blaming the model for forgetting, ask: "Was that fact on the desk for this call?"

Why Tripmate forgot "vegetarian"Step 1 of 4
  1. List what is sent each call

    Instructions (1,000 tokens), tools (1,500), history (grows every turn), plus room for the answer.

The trap is assuming a bigger window solves everything. More room means more cost per call, slower replies, and important details buried in noise. Good agents decide what goes on the desk.

Drills

Answer fast — trust the rule.

quick drill

Where does a model's answer have to fit?

quick drill

A model remembered a fact yesterday but not today in a new chat. Why?

quick drill

Which is usually the fastest-growing part of an agent's context?

quick drill

Asha's allergy note keeps getting dropped in long chats. What is the best fix?

Remember

  • The context window is the whole bundle the model sees in one call, answer included.
  • Shortcut: "Was it on the desk for this call?"
  • Trap: treating a bigger window as a cure — curate what goes in.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainWhy did the agent forget?

Late in a long chat, Tripmate suggests a non-vegetarian meal even though Asha said she was vegetarian in her first message. Explain what happened in terms of the context window and describe one design change that would prevent it.