Context Window
The maximum number of tokens an LLM can attend to in a single call.
Simple explanation
The context window is how much text the LLM can 'see' at once. If your prompt + history + retrieved context exceeds it, the model errors or truncates. Larger windows cost more.
Engineering explanation
Context windows range from 4k (older models) to 1M+ (Claude 3.5, Gemini 1.5). Cost scales with input tokens — a 100k-token prompt costs 100x more than a 1k prompt. 'Lost in the middle': models attend less to content in the middle of long contexts. Context engineering (summarise, prune, order) manages the budget.
Example
GPT-4o has a 128k context window. A 50-page document ≈ 15k tokens — fits easily. A 500-page book ≈ 150k tokens — exceeds it.
When to use it
Always — every LLM call has a context window limit. Manage it with context engineering.
Common misconception
A larger context window does NOT mean better answers. 'Lost in the middle' means models ignore content in the middle of long contexts. More context ≠ better.