The context window is the hard ceiling on prompt plus completion tokens the model can attend to in one call, fixed at training by the positional encoding scheme.
Imagine a desk where you can lay out a finite number of index cards at once. Every card is a token: words from the question, the conversation so far, plus the answer being written. The desk has a strict edge. Once the cards run past that edge, nothing more fits. The model cannot peek beyond the desk because it was only ever taught to read positions inside it. If you want to feed it a longer document, you either trim cards off the back, group several cards onto one space, or stretch the desk using a special technique designed for that. The desk size is decided when the model is built, not when you ask it a question, and it bundles both what you say and what it replies into the same finite space.
Detailed answer & concept explanation~6 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
5 min: define context window as prompt plus completion cap, trace it to positional encoding, show the KV cache scaling consequence, name the three extension techniques, then close on RAG versus bigger windows as a product call.
Real products, models, and research that use this idea.
- Gemini 3.1 Pro advertises a 2 million token context window, used heavily for whole-codebase and long-video tasks.
- Claude Opus 4.7 ships a 1 million token window, with output capped well below the input cap to manage decode cost.
- GPT-5.5 currently offers a 400k token context with prompt caching to amortise repeated long-prefix calls.
- Llama 4 Maverick was released with a 256k context that production users extend further with YaRN-style fine-tuning.
- DeepSeek V4 uses sliding window attention combined with global tokens to push effective length past its trained range.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy does long-context recall often degrade in the middle of the window even within the trained range?
QHow does the KV cache size scale, and what does that imply for million-token serving?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating the context window as input-only. The cap covers prompt plus completion combined, so a long prompt eats the budget the model has left to actually answer.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.