Context window (context windows). What it means.

A context window is the maximum amount of text, measured in tokens, that a language model can take into account at one time, including the instructions, the conversation, any documents and its own reply.

By Brady Heinrich · Updated

Definition

A context window is the maximum amount of text, measured in tokens, that a language model can take into account at one time, including the instructions, the conversation, any documents and its own reply.

What is a context window?

A context window is a model's working memory. Everything the model can "see" when it writes an answer has to fit inside it: the system instructions, the conversation so far, files you attached, results from tools and the answer being written. Anything outside the window does not exist as far as the model is concerned.

The size is measured in tokens, not words, and it differs by model. Sizes have grown quickly, from a few thousand tokens in early models to hundreds of thousands or more in current ones. Check the provider's documentation for the figure that applies to the model you use.

What counts toward the context window?

ItemNotes
System promptStanding instructions, sent on every request
Tool definitionsDescriptions of each tool the model may call
Conversation historyEvery earlier message, resent on each turn
Attached documentsFiles, retrieved passages, web pages
Tool resultsWhat searches and other tools returned
The model's outputThe reply, and any reasoning, as it is generated

What happens when the context window fills up?

It depends on the product. Some refuse the request. Some drop the oldest messages. Some summarise earlier parts of the conversation to free space. In the last two cases the model may appear to forget something you said earlier, because that text is no longer in front of it.

Is a bigger context window always better?

No. A bigger window lets you supply more, but more is not always better:

  • Cost. You pay for every input token on every turn.
  • Speed. Longer input takes longer to process.
  • Attention. Models can give less weight to details buried in the middle of a very long input, and accuracy can fall as irrelevant material piles up.

A focused 2,000-token prompt with the right passage often beats a 200,000-token one with the right passage somewhere inside.

How do you manage context well?

  1. Give the model the relevant passages, not the whole archive. Retrieval exists for this.
  2. Put key instructions at the start, and repeat the question after long documents.
  3. Start a fresh conversation when the subject changes.
  4. Summarise long threads and carry the summary forward.
  5. For agents, save notes to a file instead of relying on the conversation to hold them.

Context window vs memory

The context window is temporary. It is cleared when a conversation ends. "Memory" features work by saving notes outside the model and inserting them into the window in later sessions.

An example

An analyst pastes a 400-page annual report into an assistant and asks about one footnote. The answer is vague. She tries again with only the 12 pages of the notes section and gets a precise answer with the paragraph quoted. The model was the same both times. The second time, the relevant text made up most of the context instead of a fraction of one percent.

The common mistake

Filling the window because the space is there. Every extra document costs money, slows the answer and gives the model more to be distracted by. Curate what goes in: the question, the instructions and the smallest set of material that contains the answer.

How people search for context window

  • context window2,400 a month
  • what is a context window480 a month
  • llm context window390 a month
  • context window ai390 a month
  • context length170 a month

US monthly searches, Google Ads keyword data.

Related terms

Go deeper

Building something ambitious? Let's talk.

We reply within one business day.