Naru News日本語

Home › Glossary › AI

What is a context window in AI?

Also called: Context length

Term explainer · Checked November 8, 2026 · 11 min read

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

A figure showing what goes into a context window (box lengths are made up for this page). Title: “What the AI can look at for one reply.” At the top: “Context window (e.g. 1 million tokens).” Below it, one long band is the window, and the dotted line at its right end is the “Limit.” Inside the band, from the left: white boxes “Instructions for the AI,” “Earlier chat: Q and A,” “Attached files” and “Your question”; a striped box “The answer + thinking”; and a dotted box “Free.” A bracket under the first four says “What the AI reads (input),” and one under the striped box says “What it writes (output).” Below, in a dotted frame: “Text it was trained on. Not in the window: can’t reread it.” To the right: “The window is the AI’s ‘working memory’ (as Anthropic puts it).” Band at the bottom: It can only look back at text inside the window.
The long band is the window: what the AI can look at for one reply. White boxes are what the AI reads; the striped box is the answer it writes that turn, including any thinking it does before answering (reasoning tokens). Reading and writing together can only fill the band up to the dotted limit on the right. The huge amount of text the AI was trained on, in the dotted frame, is outside the window, so the AI cannot open it and look back at it while replying. That is why Anthropic calls the window the AI’s “working memory” (box lengths are made up for this page).
A figure showing what happens when a chat overflows the window (based on Anthropic’s docs; the number of turns is made up for this page). Title: “What if it overflows the window?” Top row, “Long chat”: boxes Q1, A1, Q2, A2, …, A9 and Q10 in a row, with Q10 crossing the dotted “Limit” line and labeled “Too long!” Below: “It depends on how the AI is used:” and three panels. Left, “It stops”: of six small boxes numbered 1 to 6, box 6 is past a dotted line, with an × mark. “An error says the ‘prompt is too long’ (the API for apps).” Middle, “Drops the oldest”: boxes 1 and 2 are dotted and labeled “dropped,” and boxes 3 to 6 remain. “Oldest parts go first (some chat screens).” Right, “Summarizes”: boxes 1 to 4 become one “Summary” box, and boxes 5 and 6 remain. “Old turns become a summary the AI wrote (compaction).” Band at the bottom: Dropped turns and details left out of a summary are gone.
The top row is a long chat in which the 10th question has gone past the window’s limit (dotted line). What happens next depends on how the AI is used. Through the API, the way apps use the AI, a request whose input alone is over the limit gets an error and no reply. Chat screens such as claude.ai may drop the oldest parts first. Anthropic’s “compaction” replaces old turns with a summary the AI writes. Either way, whatever was dropped, and any detail the summary left out, can no longer be seen.
A graph of where the answer was placed and how often the AI answered correctly (numbers from a table in Liu et al.’s 2023 paper). Title: “Answers in the middle get missed more.” Below: “Liu et al. (2023): GPT-3.5-Turbo given a question and 20 documents.” The vertical axis, “Answered correctly,” runs from 40% to 80%; the horizontal axis, “Where the document with the answer was placed, out of 20,” shows 1st, 5th, 10th, 15th and 20th. A solid line makes a U shape: 1st “First 75.8%,” 5th 57.2%, 10th “Middle 53.8%,” 15th 55.4% and 20th “Last 63.2%.” A dotted horizontal line marks “With no documents 56.1%”; the 10th and 15th points are below it. Band at the bottom: Even when it fits, the middle is used less (a U shape).
The horizontal axis shows where, among 20 documents, the one containing the answer was placed; the vertical axis shows how often the answer was correct. Placed first, it was 75.8%, and last, 63.2%, but 10th it fell to 53.8%, lower than answering with no documents at all, using only what it learned in training (dotted line, 56.1%). All 20 documents together averaged about 3,000 tokens and fit in the window (4,000 tokens). The paper links this to the “serial-position effect,” where people best remember the first and last items on a list. These are results for a 2023 model.

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

  1. 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.

    More on this → Key points: What goes into the window?

  2. 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?

  3. 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.

    More on this → Key points: What happens when it overflows?

Questions that use this term

Sources and how we checked

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].

Other terms