What is a context window in AI?
Also called: Context length
In one minute
A context window is the limit on how much text an AI can look at, all at once, while producing one reply (counted in tokens, the small pieces of text an AI reads and writes).
What goes in: the instructions for the AI, the conversation so far, any files you attached, your current question and the answer the AI is about to write. The AI company Anthropic describes it as the AI’s “working memory,” separate from the huge amount of text the AI was trained on.
GPT-3 (2020) had room for 2,048 tokens; in November 2026, newer Claude and Gemini models have 1 million. When something will not fit, the AI stops with an error, drops the oldest parts or replaces them with a summary. But Anthropic writes that the more you put in, the harder it gets for the AI to recall the contents accurately.
A common mix-up
“If it fits in the context window, the AI reads all of it equally well.”
Half right. Everything in the window is something the AI can look at when it writes a reply. But it does not use all of it equally well. Anthropic says accuracy and recall degrade as the token count grows, and calls this “context rot.” In a 2023 study by researchers at Stanford University and elsewhere, models answered correctly less often when the document with the answer sat in the middle than when it came first or last. A window’s size tells you how much fits, not how much gets used well.
Explained in pictures
Think of it like this
The size of a desk
A context window is like the size of a desk. The AI works by looking at the papers spread out on its desk (the instructions, the conversation so far, the attached files and your question), and it writes its answer on the same desk. You cannot spread papers wider than the desk. And because the answer is written on the desk too, filling the whole desk with files leaves no room to write.
What the AI learned in training is not on the desk; it is more like what is in its head. The books it learned from are not at hand. Shelves and drawers are more like an app’s “memory” feature or a search that fetches documents: the AI can only read something and use it once it has been taken out and put on the desk.
Spread too many papers, and even on a big desk it gets easier to miss the one that matters, and that is true for AI too. But the comparison has limits. A person still remembers a little about papers cleared off the desk, but an AI cannot see anything that has left the window at all for that reply. And every time the AI writes a reply, it reads all the papers on the desk again from the beginning.
Key points
What goes into the window?
According to Anthropic’s documentation, everything sent for one reply goes into the window: the instructions for the AI (the system prompt), every message in the conversation so far, the results of any tools it used (such as a search), images and documents, and the descriptions of the tools it can use. The answer the AI writes that turn goes in too. The window is the room for reading and writing together.
So if you give a model with a 100,000-token window a 99,000-token document, only about 1,000 tokens are left for the answer (an example made up for this page). Anthropic says that on newer Claude models (Claude 4.5 and later), if the answer reaches the window’s limit while it is being written, the model stops there. If the input alone is over the limit, the request fails with an error from the start.
For an AI that thinks before answering (a reasoning model), the thinking it does before the answer (reasoning tokens) also goes into that turn’s window and is counted as writing. Whether the thinking from one reply stays in the window for the next reply depends on the model; most newer Claude models keep it and count it like any other input (Anthropic’s explanation, November 2026).
Using a “cache,” which keeps what was already read so it can be reread quickly, still counts toward the window. What caching changes is the price and speed of reading those tokens, not whether they count (Anthropic’s explanation).
How big is it?
According to OpenAI’s 2020 paper, GPT-3’s window was 2,048 tokens. Google’s documentation says earlier text-generating AIs could only handle 8,000 tokens at a time, and newer ones pushed that to 32,000 or even 128,000 tokens.
In the companies’ documentation as of November 2026, Anthropic’s newer Claude models (such as Claude Opus 5.5) and Google’s Gemini 4 Argon have 1 million tokens, and OpenAI’s GPT-6 Astra has 1.05 million. In ordinary one-at-a-time use, Claude can write up to 128,000 tokens of that in a single reply.
How much is 1 million tokens? Google’s documentation compares it to “8 average length English novels,” “50,000 lines of code (with the standard 80 characters per line)” and “transcripts of over 200 average length podcast episodes,” among other things. Anthropic says that with Claude’s current tokenizer, it is roughly 555,000 words, or 2.5 million characters. But how many characters one token stands for depends on the model and the language (Anthropic’s glossary).
What happens when it overflows?
It depends on how the AI is used. Through Anthropic’s API (the gateway apps use to reach the AI), if the input alone is over the window, the request gets a “prompt is too long” error and no reply is made.
Chat screens may drop the oldest parts first. Anthropic writes that chat interfaces such as claude.ai can also manage the window on a “first in, first out” basis. Whatever is dropped can no longer be seen by the AI.
Another way is to summarize. Anthropic’s “compaction” replaces older turns with a summary the AI writes, so a conversation can keep going past the window’s limit. In a September 2025 article about Claude Code, an AI coding tool, Anthropic explained that a conversation nearing the limit is summarized by the AI, and the work continues from that summary plus the five most recently accessed files. But details that drop out of the summary cannot be seen later, even if they are needed. For when the summary leaves out something important, the documentation also lets you write your own instructions for how to summarize.
Is a bigger window always better?
Having room for more is handy, but Anthropic writes that more context isn’t automatically better: as the token count grows, accuracy and recall degrade. It calls this “context rot,” and describes it as a gradual decline rather than a point where the AI suddenly cannot read (“a performance gradient rather than a hard cliff”).
In the 2023 paper “Lost in the Middle,” researchers at Stanford University and elsewhere gave AIs a question and 20 documents and moved the one document containing the answer to different places. GPT-3.5-Turbo answered correctly 75.8% of the time when that document came first and 63.2% when it came last, but only 53.8% when it was 10th, lower than the 56.1% it got with no documents at all, using only what it learned in training. With all 20 documents, the input averaged about 3,000 tokens (at most 3,920), within its 4,000-token window. The paper also says that models with extended windows are not necessarily better at using what is in them.
Google’s documentation likewise says that while a model can find a single piece of information about 99% of the time, it does not perform with the same accuracy when looking for several, and performance can vary widely. The other issue is price. Where you pay for what you use, you pay for the input tokens every time you send a long document. With OpenAI’s GPT-6 Astra, a request with more than 272,000 input tokens costs twice as much for input and 1.5 times as much for output (November 2026).
Why is there a limit?
When it writes an answer, the design most of today’s AIs use (the Transformer) compares the tokens in the window with each other and works out which ones are most closely related (a calculation called attention). Double the tokens and the pairs to compare roughly quadruple; ten times the tokens, about a hundred times the pairs (just as doubling the size of a class roughly quadruples the number of possible pairs of students). The 2017 paper also shows this work growing with the square of the text’s length.
Anthropic writes that as the context gets longer, there are so many pairs that a model’s ability to capture each relationship gets “stretched thin.” It also explains that models learn how to spread their attention from their training data, where shorter texts are more common, so they have less experience with relationships that span a whole long text. A bigger window means heavier calculation, and even when the window is bigger, the model does not necessarily make good use of everything in it.
Any tips for giving an AI long documents?
Anthropic’s documentation recommends that for long documents (about 20,000 tokens or more), you put the documents near the top of your prompt (the text you give the AI) and your question and instructions at the end. It says that in tests, putting the question at the end improved answer quality by up to 30% (the company’s own claim). Google’s documentation also says that when the context is long, the model usually does better if the question comes at the end.
Anthropic also suggests wrapping each document in its own tags (XML tags) with its source when there are several, and asking the AI to quote the relevant parts of the documents before it answers. Anthropic’s article for people building AI agents recommends finding the smallest set of useful information that gets you the result you want. However big the window, choosing what goes in matters.
How is it different from what the AI learned, or a “memory” feature?
It is separate from what the AI learned. Anthropic’s glossary describes the context window as the AI’s “working memory,” different from the huge body of text it was trained on. The AI cannot open the text it was trained on and look back at it while replying. What it can look back at, right then, is only the text in the window.
Anthropic’s memory tool lets the AI write down what it wants to keep in files outside the window and read them back in a later conversation when needed, so it can build up knowledge without keeping everything in the window. “Retrieval-augmented generation” (RAG), which looks up documents and puts them into the window, likewise brings in information from outside the window, only as much as is needed. Either way, in the end the AI reads it inside the window.
Check yourself
Q1A context window (the limit on how much an AI can look at for one reply) is shared by two things. Which two?
Answer and explanation
Answer: C The text you give the AI and the answer it writes
The window holds the text you give the AI (instructions, the conversation so far, documents and your question) and the answer the AI writes that turn, and they share the same room. Give a 99,000-token document to an AI with a 100,000-token window, and only about 1,000 tokens are left for the answer. The text it was trained on is outside the window and cannot be looked back at while it replies.
Q2In a 2023 study, researchers gave an AI (GPT-3.5-Turbo) a question and 20 documents and moved the one document with the answer to different places, such as 1st, 10th and 20th. Where was that document when the AI answered correctly least often?
Answer and explanation
Answer: A 10th of the 20
With the answer document first, it answered correctly 75.8% of the time, and last, 63.2%, but 10th it fell to 53.8%, lower than the 56.1% it got with no documents. Even inside the window, information in the middle gets used less (Liu et al., “Lost in the Middle”).
More on this → Key points: Is a bigger window always better?
Q3In a very long chat with an AI, the conversation no longer fits in the context window (the limit on how much the AI can look at for one reply). What might the chat screen or AI tool do?
Answer and explanation
Answer: B Swap the old messages for a short summary
Anthropic’s compaction replaces old turns with a summary the AI writes, and chat screens such as claude.ai may also drop the oldest parts first. The window is separate from training, and it is counted in tokens, so the size of the print makes no difference. Whatever was dropped, and details left out of a summary, can no longer be seen.
Related terms
- Token
- Large language model
- Transformer
- Reasoning model
- AI agent
- Retrieval-augmented generation (RAG)
- Prompt
Questions that use this term
Sources and how we checked
- Anthropic, "Context windows" (Claude docs; read November 8, 2026)
- Anthropic, "Glossary" (Context window, Tokens; read November 8, 2026)
- Anthropic, "Models overview" (model comparison table; read November 8, 2026)
- Anthropic, "Compaction overview" (read November 8, 2026)
- Anthropic, "Prompt caching" (read November 8, 2026)
- Anthropic, "Prompting best practices" (Long context prompting; read November 8, 2026)
- Anthropic, "Memory tool" (read November 8, 2026)
- Anthropic, "Effective context engineering for AI agents" (September 29, 2025; read November 8, 2026)
- Google, "Long context" (Gemini API docs; read November 8, 2026)
- Google, "Models" (Gemini API docs; Gemini 4 Argon; read November 8, 2026)
- OpenAI, "GPT-6 Astra" (API docs; read November 8, 2026)
- Brown et al., "Language Models are Few-Shot Learners" (OpenAI, arXiv, May 2020; GPT-3; read November 8, 2026)
- Vaswani et al., "Attention Is All You Need" (Google Brain, Google Research and others, arXiv, June 2017; read November 8, 2026)
- Liu et al., "Lost in the Middle: How Language Models Use Long Contexts" (Stanford University, University of California, Berkeley, and Samaya AI, arXiv, July 2023; accepted to TACL; read November 8, 2026)
AI wrote this page from the sources above, and a different AI checked it against the text of those sources (November 8, 2026). A person with a master’s degree in science and a Japanese high-school science teaching license also read and checked it before publishing. Numbers are as of that date. If anything was hard to follow, you spot a mistake, or there’s a term you’d like explained, please write to [email protected].