What is a context window in AI?
A context window is how much text an AI model can see at once, counted in tokens: your prompt, the chat so far and its reply.
Rung 1 Explain like I'm 6
Imagine doing homework at a small desk. Everything you need has to fit on the desk: the question, your notes, and the page you are writing on. If you pile on too many papers, some fall off the back, and you cannot look at them any more.
An AI chatbot has a desk like that. It can only "see" what is on its desk right now. That desk is called the context window. A bigger desk lets it look at a whole book at once. But even on a big desk, things buried in the middle of a messy pile are easy to miss.
Rung 2 High-school level
A context window is the most text a language model can take in and work with at one time. It is measured in tokens, small chunks of text, often a word or part of a word.
Everything counts: hidden instructions from the app (the system prompt), your message, the earlier chat, any files you upload, and the model's own reply [7]. The model has no other memory of your chat. Each time you send a message, the app sends the whole conversation again.
Context window vs token limit: the window is the whole desk. A token limit usually caps one part, most often how long a single reply may be. Current Claude models (November 2026) have a 1-million-token window but can write at most 128,000 tokens in one reply [7].
How big is a million tokens? Google's docs say roughly 8 average-length novels, or 50,000 lines of code [8].
"Context window full" in ChatGPT or Claude means the chat has hit the limit. Apps then drop the oldest messages or summarise them, which is why a very long chat can "forget" its start [7].
Check yourself: Does a model's own reply count towards its context window?
Yes. The window holds the prompt, the earlier conversation and the reply being written.
Rung 3 Undergraduate level
A transformer reads a sequence of token positions. Each layer lets every token attend to every earlier token, and a position encoding (today usually RoPE, which rotates vectors by position) tells the model where each token sits. The context window is the longest sequence the model was built and trained to handle.
Two costs grow with length. Attention compares every token with every other, so compute grows with the square of the length. And during generation the model stores keys and values for every past token in a KV cache, so memory grows linearly. For Llama 3 70B that is about 320 KiB per token, or about 43 GB at 128K tokens, on top of the weights (worked out on the KV cache page).
A worked budget for one API call to a model with a 200,000-token window:
- system prompt: 3,000
- tool definitions: 7,000
- earlier conversation and tool results: 150,000
- new user message: 2,000
- room left for the reply: 200,000 − 162,000 = 38,000
If you ask for a 50,000-token reply, it will be cut off when the window fills. If the input alone is bigger than the model's window (200,000 in this example), the Claude API rejects the request with a "prompt is too long" error [7].
This is why agents that call many tools run out of room: every tool result stays in the conversation unless something removes or summarises it.
Rung 4 Graduate level
The number on the box is the nominal window. What matters is the effective window: how long an input can get before accuracy drops.
Position matters. Liu et al. (2023) found models do best when the relevant text is at the start or end of the input, and worse when it is in the middle [1].
Claimed vs real. RULER (2024) tested 17 long-context models, all claiming at least 32K tokens, on 13 tasks beyond simple retrieval. Only half kept satisfactory performance at 32K [2].
Literal matching hides the problem. "Needle in a haystack" tests plant a sentence and ask for it using the same words. NoLiMa (2025) removed that word overlap. Of 13 models claiming at least 128K tokens, 11 fell below half their short-input score at 32K; GPT-4o dropped from 99.3% to 69.7% [4].
The engineering trade-offs that follow:
- Long context vs RAG. Pasting everything is simple and avoids retrieval misses, but costs more and suffers these accuracy losses. Retrieving a few good passages is cheaper and often more accurate.
- Cost and latency. Price is per token, and the model must process the whole input before the first output token appears. Prompt caching cuts the cost of re-sending the same prefix, but cached tokens still occupy the window [7].
- Curation over capacity. Anthropic's docs call the accuracy decline with length context rot and say curating what goes into the window matters as much as its size [7].
Check yourself: What is the difference between a model's nominal and effective context window?
Nominal is the most tokens it accepts; effective is how long the input can be before its accuracy noticeably drops.
Rung 5 PhD level
Why are windows finite at all? Three limits interact.
- Training length. A model learns to use positions it saw in training. Beyond them, attention patterns and position encodings drift out of distribution. Methods that rescale RoPE frequencies extend the window cheaply: YaRN (2023) extended LLaMA models using 10× fewer tokens and 2.5× fewer training steps than earlier methods [3]. Extending what a model accepts is easier than extending what it uses well.
- Compute. Full attention is quadratic in length, so most long-context models rely on efficient kernels, sparse attention, or hybrids with cheaper layers.
- Memory. The KV cache grows with every token and every concurrent user, which ties context length to serving cost.
Measurement is its own problem. Single-needle retrieval is close to solved and says little [8]. Harder probes, multi-hop reasoning, aggregation, and questions with no word overlap with the answer [4], show steep declines well inside nominal limits [2]. Chroma's 2025 study of 18 models found performance "grows increasingly unreliable as input length grows" even on simple tasks [5].
Open problems:
- Length generalisation: why models trained at length L fail at 2L, and whether any architecture generalises reliably.
- Reasoning over long inputs, not just finding facts in them.
- What to keep. Agents produce more context than any window holds. Summarisation loses detail; retrieval can miss what matters. There is no theory of which tokens a future step will need.
- Fixed-size memory vs exact recall. Linear-attention and state-space layers keep constant memory but cannot store every detail, which is why most designs keep some full attention.
Rung 6 State of the art: what experts work on now
Last checked 18 November 2026.
As of 2026-11-18.
Million-token windows became normal. Anthropic's Claude Opus 4.6 (5 February 2026) was its first Opus model with a 1M-token window, in beta, with prompts over 200K billed at a higher rate. On the 8-needle 1M variant of the MRCR v2 benchmark it scored 76%, against 18.5% for Sonnet 4.5 (vendor figures) [6]. By November 2026 Anthropic's docs list 1M tokens as the default for its current models, with no beta flag and standard pricing on most of them, and up to 128K output tokens per request [7]. Google's docs describe 1M-token windows for current Gemini models [8].
The focus moved from size to management. Studies in 2025 showed accuracy falling with length well inside advertised windows [4][5], and "context rot" is now vendor vocabulary [7]. Anthropic offers server-side compaction, which summarises earlier conversation so it can continue past the limit, in beta for Claude 4.6 and later models [7].
Practical rule for 2026: a big window is a ceiling, not a promise. Put the important material at the start or end, keep the window lean, and test on your own long inputs.
Sources
- Liu et al., Lost in the Middle: How Language Models Use Long Contexts (2023)
- Hsieh et al., RULER: What's the Real Context Size of Your Long-Context Language Models? (2024)
- Peng et al., YaRN: Efficient Context Window Extension of Large Language Models (2023)
- Modarressi et al., NoLiMa: Long-Context Evaluation Beyond Literal Matching (2025)
- Chroma, Context Rot: How Increasing Input Tokens Impacts LLM Performance (2025)
- Anthropic, Introducing Claude Opus 4.6 (2026)
- Claude API docs, Context windows (2026)
- Google AI Studio docs, Long context (2026)