be/brief
Request access
← Briefly
Concept

What is a context window?

The short answer

A context window is the maximum amount of text a language model can process in one operation, measured in tokens. It holds everything the model sees at once: the system prompt, conversation history, any attached documents, and the model's own outputs. When that limit is reached, earlier content must be dropped or compressed before the model can continue.

Send a language model a 50-page contract and ask it to find the indemnity clause. Whether it succeeds depends on two things: whether the clause fits inside the model’s context window at all, and where in that window it ends up.

What the context window holds

Everything the model sees in a single call is pooled into one sequence of tokens, the subword units LLMs process rather than raw characters or words. That sequence includes the system prompt (standing instructions or persona), the full conversation history, any documents or tool outputs attached to the request, and the model’s own generated responses.

All of this counts against the same budget. A system prompt that runs 2,000 tokens leaves that much less room for conversation and documents. When the combined count exceeds the limit, the platform must drop or compress something, typically the oldest turns in the conversation, before the model can proceed. The model has no access to anything trimmed out; from its perspective, that content never existed.

The context window holds only what you explicitly provide in the current call. Unlike training knowledge, which is fixed at training time, nothing persists between calls unless you send it again.

Why there is a size limit

The limit is architectural. In the transformer model introduced by Vaswani et al. in 2017 (arXiv:1706.03762), the attention mechanism compares every token in the sequence against every other token. That pairwise comparison scales quadratically: double the sequence length and the computation roughly quadruples. Early transformer-based LLMs operated with windows of around 2,000 tokens, where this cost was manageable.

Since then, techniques like Rotary Position Embedding (RoPE) have made it possible to extend context windows without retraining from scratch. Commercial models moved from 2,000 tokens to 32,000, then to 128,000, and by 2024 some systems claimed windows reaching into the millions. Gemini 1.5’s technical report (arXiv:2403.05530) described a production context length of up to one million tokens.

Models don’t attend evenly across a long context

This is the part most overviews skip. Liu et al. ran multi-document question-answering and key-value retrieval experiments and found that models perform best when relevant information is positioned at the beginning or end of the input, and significantly worse when that information is buried in the middle, even in models explicitly trained for long contexts (“Lost in the Middle: How Language Models Use Long Contexts,” arXiv:2307.03172).

The effect held across multiple model families and at context lengths from 1,000 to 8,000 tokens. Longer windows do not resolve it; they extend the window’s reach while leaving the positional sensitivity intact.

In practice, placement matters. Critical instructions and high-priority content placed early or at the end of a prompt tend to receive more reliable attention than identical content dropped in the middle of a long document.

A larger window makes room for more input. It does not guarantee the model processes all of it with equal fidelity.

Questions, answered

Does a larger context window mean the model knows more?

No. A context window holds what you provide in the current session; what the model knows comes from training data, which is fixed at training time. Larger windows let you send more information at inference time, not learn more.

What happens when you exceed the context window?

Earlier content is truncated or compressed. Chat applications typically drop the oldest conversation turns; retrieval pipelines may chunk or summarise prior content. The model cannot see anything that has been trimmed out.

Why does context window size affect API cost?

LLM APIs charge by token. Every request pays to process all tokens in the input: system prompt, full conversation history, any attached documents. A 50,000-token context costs proportionally more per call than a 2,000-token one.

Is a million-token context window actually usable?

With caveats. Research has shown that models attend more reliably to information near the beginning or end of a long context than to information in the middle, even in models built for long contexts (Liu et al., 2023, arXiv:2307.03172). A large window expands what you can send; it does not guarantee even attention across all of it.

Brief is a team of AI associates you direct in plain language. Opening to a small group at a time.

Request access