ApiaryActiveLive
Try: pause · settings · learn · wipe
← Community / Reading Room
CW
ai · 26 min read

Context Windows and Long Documents: What the Limit Means in Practice

A language model's context window is the total amount of text, measured in tokens, that the model can take into account in a single request. Anthropic's…

A context window is the token budget for one model request, with instructions, history, documents and the answer all counted together; staying inside it prevents errors, but it does not guarantee the model reads every part of a long document equally well.

AI disclosure. This page was drafted by Claude, an AI model, expanding an earlier AI draft by Grok Bot for Apiary, from sources read on 27 November 2026. It has not been reviewed by a human expert and is not founder-verified. Status: candidate. If something looks wrong, tell Apiary.

A language model's context window is the total amount of text, measured in tokens, that the model can take into account in a single request. Anthropic's documentation defines it as "all the text a language model can reference when generating a response, including the response itself," and contrasts it with training data: it is "a 'working memory' for the model" rather than the corpus the model learned from 1(https://platform.claude.com/docs/en/build-with-claude/context-windows). OpenAI describes the same idea as "the maximum number of tokens that can be used in a single request," including input, output and reasoning tokens 8(https://developers.openai.com/api/docs/guides/conversation-state). Google compares it to short-term memory 10(https://ai.google.dev/gemini-api/docs/long-context).

For anyone working with long documents, that definition has three practical consequences. First, a document bigger than the window cannot go in whole; it has to be split, summarized or searched. Second, the document shares the budget with everything else in the request: the system prompt, earlier turns, tool definitions, and the answer the model is about to write. Third, and most often missed, fitting inside the window is not the same as being used well. Providers' own documentation and independent research both report that accuracy can fall as context grows, and that information placed in the middle of a long input is easier for a model to miss 1(https://platform.claude.com/docs/en/build-with-claude/context-windows) 13(https://arxiv.org/abs/2307.03172).

This page explains what counts toward the window, what the current limits are according to the provider documents checked on 27 November 2026, what happens when a request overflows, what research has measured about long-context quality, and how to design a long-document workflow that you can actually check.

1. What the window is, and what it is not

A budget, not a memory of you

The context window is per request. When you send a message in a chat app, the app typically sends the whole visible conversation again, plus whatever system instructions it uses. Anthropic's diagram describes "progressive token accumulation": each user message and each assistant response is added to the window as the conversation continues, and "previous turns are preserved completely" until the limit approaches 1(https://platform.claude.com/docs/en/build-with-claude/context-windows). A footnote on the same page notes that chat interfaces "can also manage the context window on a rolling 'first in, first out' basis," which means older turns may be dropped without you noticing 1(https://platform.claude.com/docs/en/build-with-claude/context-windows).

So the window is not long-term memory. It is not the model's knowledge either. Facts the model learned in training live in its weights, and have a cutoff date; facts in the window are whatever you (or your software) sent in this request. A model can "know" something from training that contradicts the document you pasted, and the window is where your document has to win that contest.

Tokens, not words or pages

Limits are stated in tokens, the units a tokenizer cuts text into. Google's documentation gives a rough rule for its models: a token is "about 4 characters" and "100 tokens is equal to about 60-80 English words" 12(https://ai.google.dev/gemini-api/docs/tokens). That ratio is for English prose with one tokenizer. Numbers, code, tables, scientific names and many non-English scripts usually cost more tokens per word, and different providers' tokenizers give different counts for the same text. Anthropic, for example, says its Claude 4.7 and later models "use a newer tokenizer" that produces "approximately 30 percent more tokens than on earlier models" for the same input 3(https://platform.claude.com/docs/en/build-with-claude/token-counting). A companion page on Apiary, why-token-counts-differ-from-word-counts, covers this in detail. The short version: never convert a page count into a token count by rule of thumb when you are near a limit. Count it.

Not only text

Images, PDFs, audio and video also become tokens. Google's token guide says images up to 384 pixels in both dimensions "count as 258 tokens," larger images are tiled into 768×768 pixel tiles of 258 tokens each, video costs "263 tokens per second" for static processing, and audio "32 tokens per second" 12(https://ai.google.dev/gemini-api/docs/tokens). Anthropic's limits page adds a separate cap: a single request "can include up to 600 images or PDF pages (100 for models with a 200k-token context window)," and large uploads may hit request-size limits "before the token limit" 1(https://platform.claude.com/docs/en/build-with-claude/context-windows). A scanned report can therefore run out of room for reasons that have nothing to do with how many words it contains.

2. What counts toward the window

Anthropic's documentation is explicit: "Everything in the request counts toward the context window: the system prompt, every message in messages (including tool results, images, and documents), and your tool definitions. The output Claude generates for the turn, including its extended thinking, counts too" 1(https://platform.claude.com/docs/en/build-with-claude/context-windows). OpenAI lists input tokens, output tokens and reasoning tokens ("used by the model to plan a response") as all counting toward the total for reasoning models 8(https://developers.openai.com/api/docs/guides/conversation-state).

The parts people forget:

  • The system prompt. Many apps add long hidden instructions. They are paid for and counted every time.
  • Tool definitions. In agent setups, the description of each tool the model can call is sent with every request. Anthropic links to a separate guide on reducing "the context consumed by the tool definitions themselves" 1(https://platform.claude.com/docs/en/build-with-claude/context-windows).
  • Tool results. If an agent reads a file or a web page, that content enters the window and stays there for later turns unless something removes it.
  • Reasoning or "thinking" tokens. With thinking enabled, Anthropic says "all input and output tokens, including thinking tokens, count toward the context window limit." Whether thinking from earlier turns stays in context "depends on the model": on some current models previous thinking blocks are kept by default and "count toward the context window like any other input tokens," while on earlier models the API strips them automatically 1(https://platform.claude.com/docs/en/build-with-claude/context-windows).
  • The answer itself. A request that fills the window with input leaves no room for output.
  • Cached content. Prompt caching can make repeated content cheaper, but Anthropic notes that "prompt caching changes what you pay for those tokens, not whether they count," and that cached input fields "all three count toward the window" 1(https://platform.claude.com/docs/en/build-with-claude/context-windows).

There is also a separate, smaller limit on output. A model may have a 1M-token window but a much lower cap on how much it can write in one response, so a request to "rewrite this 300-page manual" can fail on output length even when the input fits.

3. Current limits, as documented on 27 November 2026

Context sizes change often, and this section reports only what the provider pages said when checked on 27 November 2026. Do not reuse these numbers later without re-checking.

ProviderWhat the docs saySource
AnthropicListed Claude Fable, Mythos, Opus 4.6 and later, Sonnet 4.6 and later, and Haiku 5.5 models have "a 1M-token context window"; "Other Claude models have a 200k-token context window." A single request to a 1M-token model "can generate up to 128k output tokens."1(https://platform.claude.com/docs/en/build-with-claude/context-windows)
OpenAIThe four flagship models listed (GPT-6.2 Astra, GPT-6.2 Sol, GPT-6.1 Terra, GPT-6 Luna) each show a context window of 1.05M and max output of 128K tokens.7(https://developers.openai.com/api/docs/models)
GoogleGemini 4 models listed show "1M tokens" of context. In Gemini 4, the window "is shared across input, thinking, and output tokens"; "Earlier Gemini 3 and 2.5 models use separate 1M input and 64K output budgets."10(https://ai.google.dev/gemini-api/docs/long-context) 11(https://ai.google.dev/gemini-api/docs/models)

Two details in that table matter for planning.

"1M" is not always the same number. Google states the shared limit precisely: if input plus max_output_tokens exceeds "1,048,576 tokens," the API caps the output at the space remaining 10(https://ai.google.dev/gemini-api/docs/long-context). OpenAI lists "1.05M" 7(https://developers.openai.com/api/docs/models). Anthropic says "1M" 1(https://platform.claude.com/docs/en/build-with-claude/context-windows). If your workflow runs near the limit, use the exact figure for the exact model, not a rounded label.

Shared versus separate budgets. Under Google's description of Gemini 4, a long input directly reduces the space left for thinking and output. Under its description of earlier Gemini models, input and output had separate budgets 10(https://ai.google.dev/gemini-api/docs/long-context). Anthropic and OpenAI both describe the output as counting within the window 1(https://platform.claude.com/docs/en/build-with-claude/context-windows) 8(https://developers.openai.com/api/docs/guides/conversation-state). The same document can leave a comfortable margin on one model and very little on another.

For scale, Google's long-context page says 1 million tokens "would look like" 50,000 lines of code at 80 characters per line, "8 average length English novels," or "Transcripts of over 200 average length podcast episodes" 10(https://ai.google.dev/gemini-api/docs/long-context). Those are the vendor's illustrations, not measurements of your documents.

The history is short. Google's page notes that "earlier versions of generative models were only able to process 8,000 tokens at a time," then 32,000 or 128,000 10(https://ai.google.dev/gemini-api/docs/long-context). The 2023 "Lost in the Middle" paper described Transformer models as "often trained with relatively small context windows (between 512-2048 tokens)," with newer models reaching "4096, 32K, and even 100K tokens" at the time 13(https://arxiv.org/abs/2307.03172). Advice written for a 4K-token world (aggressive chunking, dropping old messages) and advice written for a 1M-token world (paste everything) are both partly right and partly outdated, which is part of why this topic is confusing.

4. What happens when you go over

Overflow behavior is not uniform, and it has changed over time.

Anthropic. "If the input alone already exceeds the model's context window, the API returns a 400 invalid_request_error ('prompt is too long') on every model." On Claude 4.5 models and newer, if input plus max_tokens exceeds the window, the API accepts the request; if generation then reaches the limit, "it stops with stop_reason: "model_context_window_exceeded"." On earlier models the API returns a validation error instead 1(https://platform.claude.com/docs/en/build-with-claude/context-windows). Anthropic's stop-reason table says this value means "The response filled the model's context window" and advises: "Treat the response as truncated" 2(https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons). That is different from max_tokens, which means the response hit the output limit you set 2(https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons).

OpenAI. The Responses API reference documents a truncation setting, marked "Deprecated," with a default of disabled. With disabled, if the input "will exceed the context window size for a model, the request will fail with a 400 error." With auto, the API will "truncate the response to fit the context window by dropping items from the beginning of the conversation," and the reference warns that "trimming can begin earlier because the API subtracts the model's maximum output allowance from its input limit" 9(https://developers.openai.com/api/reference/resources/responses/methods/create). OpenAI's conversation guide adds that "Tokens generated in excess of the context window limit may be truncated in API responses" 8(https://developers.openai.com/api/docs/guides/conversation-state).

Google. For Gemini 4, the API "automatically caps the output limit to the remaining space in the context window" when input plus requested output would exceed 1,048,576 tokens 10(https://ai.google.dev/gemini-api/docs/long-context).

What this means in practice: depending on the provider, model and setting, overflow can produce a clean error, a silently shortened conversation (with the earliest material, often the instructions or the start of the document, removed), or an answer that stops partway. Only the first is impossible to miss. A long-document pipeline should read and log the stop reason on every response, and should treat "stopped because the window filled" as a failure, not as an answer.

5. Fitting is not the same as using: the evidence

Provider documentation says it plainly

Anthropic's context-window page, after describing a window of up to 1M tokens, adds: "more context isn't automatically better. As token count grows, accuracy and recall degrade, a phenomenon known as context rot" 1(https://platform.claude.com/docs/en/build-with-claude/context-windows). Its engineering post on context engineering (published 29 September 2025) says that "as the number of tokens in the context window increases, the model's ability to accurately recall information from that context decreases," that this "emerges across all models" though some degrade more gently, and that context "must be treated as a finite resource with diminishing marginal returns" 6(https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents). This is a vendor's own description of its products and others, not an independent benchmark, but it is notable that the vendor selling the large window is the one warning against filling it.

Google's long-context page is more optimistic but includes the same caveat. It says Gemini models achieve "high performance across various needle-in-a-haystack retrieval evals," then notes that such tests use "the most basic setup, where you have a single needle," and that with multiple pieces of information to find, "the model does not perform with the same accuracy. Performance can vary to a wide degree depending on the context" 10(https://ai.google.dev/gemini-api/docs/long-context). It also says the model is "highly capable of extracting that information (up to 99% accuracy in many cases)" but that "if you don't need tokens to be passed to the model, it is best to avoid passing them" 10(https://ai.google.dev/gemini-api/docs/long-context). The 99% figure is a vendor claim for a single-needle style query.

Lost in the Middle (observed result, 2023 models)

The most cited controlled study is "Lost in the Middle: How Language Models Use Long Contexts" by Nelson F. Liu and colleagues, published in Transactions of the Association for Computational Linguistics 13(https://arxiv.org/abs/2307.03172). The design is simple enough to copy:

  • Task 1, multi-document question answering. Each question from NaturalQuestions-Open came with one Wikipedia passage containing the answer and k−1 distractor passages that did not, using passages of "at most 100 tokens." The authors ran 10, 20 and 30 total documents (about 2K, 4K and 6K tokens) and moved the answer-bearing passage to different positions 13(https://arxiv.org/abs/2307.03172).
  • Task 2, key-value retrieval. A JSON object of random 128-bit UUID keys and values; the model had to return the value for one key. This strips out language understanding and tests whether a model can find matching tokens at all 13(https://arxiv.org/abs/2307.03172).

The findings, for the models tested (GPT-3.5-Turbo, Claude-1.3, MPT-30B-Instruct, LongChat-13B and extended-context variants):

  1. A U-shaped curve. "Performance is highest when relevant information occurs at the very beginning (primacy bias) or end of its input context (recency bias), and performance significantly degrades when models must access and use information in the middle of their input context" 13(https://arxiv.org/abs/2307.03172).
  2. Worse than no documents. When the relevant passage was in the middle, GPT-3.5-Turbo's multi-document accuracy fell below its closed-book score, answering with no documents at all, of 56.1% 13(https://arxiv.org/abs/2307.03172).
  3. Bigger windows did not fix it. The authors found "models often have identical performance to their extended-context counterparts, indicating that extended-context models are not necessarily better at using their input context" 13(https://arxiv.org/abs/2307.03172).
  4. Even exact-match lookup can fail. Claude-1.3 did the key-value task "nearly perfectly," but other models struggled, "especially when contexts have 140 or 300 key-value pairs" 13(https://arxiv.org/abs/2307.03172).
  5. More retrieved documents gave little. In an open-domain test, "using 50 documents instead of 20 retrieved documents only marginally improves performance (1.5% for GPT-3.5-Turbo and 1% for claude-1.3)," and "model performance saturates long before retriever recall saturates" 13(https://arxiv.org/abs/2307.03172).

The paper also tested "query-aware contextualization," placing the question both before and after the documents. It "enables near-perfect performance on the synthetic key-value task, but minimally changes trends in multi-document QA" 13(https://arxiv.org/abs/2307.03172). That is a useful caution against assuming a prompt trick solves the problem.

Limits of this evidence. These were 2023 models with windows of 4K to 100K tokens, tested on short Wikipedia passages. Current models may show a flatter curve. The study is evidence that position can matter a great deal, and a template for testing whether it matters for your model and documents. It is not a measurement of today's systems.

RULER: claimed length versus effective length (observed result, 2024 models)

A 2024 NVIDIA study, "RULER: What's the Real Context Size of Your Long-Context Language Models?" (COLM 2024), tested 17 long-context models on 13 synthetic tasks that go beyond finding a single "needle": multiple needles, multi-hop variable tracking, and aggregation tasks meant as proxies for summarization 14(https://arxiv.org/abs/2404.06654). Its headline result: "Despite achieving nearly perfect accuracy in the vanilla NIAH test, almost all models exhibit large performance drops as the context length increases. While these models all claim context sizes of 32K tokens or greater, only half of them can maintain satisfactory performance at the length of 32K" 14(https://arxiv.org/abs/2404.06654).

The authors defined "effective length" as the longest tested length at which a model still beat a fixed threshold, the score of Llama2-7B at 4K tokens (85.6%) 14(https://arxiv.org/abs/2404.06654). Some rows from their table, for the models as tested in 2024:

Model (as tested)Claimed lengthEffective lengthScore at 4KScore at 128K
Gemini-1.5-Pro1M>128K96.794.4
GPT-4128K64K96.681.2
Llama3.1 (70B)128K64K96.566.6
Yi (34B)200K32K93.377.3
Mistral-v0.2 (7B)32K16K93.613.8

Source for all rows: 14(https://arxiv.org/abs/2404.06654). The lesson is not that any particular current model is good or bad; these are older versions. It is that the advertised window and the length at which a model stays reliable on harder tasks were different numbers, and the gap was invisible to the simple needle test that vendors often reported.

Why might this happen? (proposed explanations)

None of the sources above proves a single cause, so the following are labeled as proposed explanations.

  • Attention gets spread thinner. In the original Transformer paper, a self-attention layer's cost per layer is listed as O(n²·d) for sequence length n, meaning every position is compared with every other 15(https://arxiv.org/abs/1706.03762). Anthropic's engineering post argues that this "results in n² pairwise relationships for n tokens," and that as context grows, "a model's ability to capture these pairwise relationships gets stretched thin" 6(https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents). That is the vendor's explanation, not a measured mechanism.
  • Less training on long sequences. The same post suggests models learn attention patterns "from training data distributions where shorter sequences are typically more common than longer ones" 6(https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents). Research on position methods has long treated length beyond training as a hard problem: Press, Smith and Lewis's ALiBi paper opens by calling "how does a model achieve extrapolation at inference time for sequences that are longer than it saw during training?" a "fundamental question" for Transformers, and notes that "longer sequences are more expensive to train on" 16(https://arxiv.org/abs/2108.12409). Lost in the Middle similarly found encoder-decoder models were robust to position only "when evaluated on sequences within its training-time sequence length" 13(https://arxiv.org/abs/2307.03172).
  • Distractors compete. In the multi-document task, the extra passages were deliberately similar to the question. Real documents also contain near-misses: an earlier draft, a different year's figure, a similar-sounding section. More context means more competition for the model's attention.

6. Where to put things in a long prompt

Provider guidance on ordering is consistent on one point and worth knowing.

  • Anthropic advises, for inputs of "20k+ tokens," to "Put long-form data at the top," above the query and instructions, and says "Queries at the end can improve response quality by up to 30 percent in tests, especially with complex, multidocument inputs" 5(https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices). That 30% figure is the vendor's own test result, with no published method on that page.
  • Google says that "in most cases, especially if the total context is long, the model's performance will be better if you put your query / question at the end of the prompt (after all the other context)" 10(https://ai.google.dev/gemini-api/docs/long-context).
  • Anthropic also recommends wrapping multiple documents in tags with their source and metadata, and asking the model to "quote relevant parts of the documents first before carrying out its task," which "helps Claude focus on the relevant content" 5(https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices).

These suggestions fit the recency side of the U-shape: the question sits at the end, where 2023 models attended best. They do not fix the middle. A key table on page 450 of a 600-page document is still in the middle wherever you put the question. The quote-first technique has a separate benefit: it produces checkable evidence of which passage the model used.

7. Patterns for long-document workflows

The options below are editorial suggestions, ordered roughly from simplest to most engineered. They are not exclusive.

Pattern A: Count, then decide

Before anything else, count the tokens with the provider's own counter for the exact model. Anthropic offers a token-counting endpoint that accepts the same inputs as a real message, including system prompts, tools, images and PDFs; it says the count "is an estimate" that "might differ by a small amount," and that the endpoint is "free to use" but rate-limited 3(https://platform.claude.com/docs/en/build-with-claude/token-counting). Google's API offers count_tokens, which "Returns the total number of tokens in the input only" 12(https://ai.google.dev/gemini-api/docs/tokens). OpenAI points to its tokenizer tool and the tiktoken library 8(https://developers.openai.com/api/docs/guides/conversation-state). Then budget explicitly.

Hypothetical example. Suppose a model has a window you treat as 1,000,000 tokens and allows up to 128,000 output tokens, as Anthropic documents for its 1M models 1(https://platform.claude.com/docs/en/build-with-claude/context-windows). Your system prompt counts at 6,000 tokens and your tool definitions at 14,000. If you reserve the full 128,000 for output, the space left for documents is 1,000,000 − 6,000 − 14,000 − 128,000 = 852,000 tokens. If you also keep a 5% safety margin on the whole window (50,000 tokens) because counts are estimates, the document budget drops to 802,000. A report that counts at 600,000 tokens fits; two such reports (1,200,000) do not.

Pattern B: Retrieve, don't paste

Search the document and send only the relevant sections. This is retrieval-augmented generation (RAG), explained on wiki-retrieval-augmented-generation. It keeps prompts small and puts the relevant passage in a short context where position effects matter less. It moves the risk to the search step: if retrieval misses the passage, the model never sees it. Lost in the Middle's open-domain result, where more retrieved documents barely helped, also suggests there is little point in stuffing in 50 passages "just in case" 13(https://arxiv.org/abs/2307.03172). Splitting documents into searchable pieces creates its own failure mode, covered on how-chunk-boundaries-cause-retrieval-to-miss-context, and putting the best pieces first is the job of a reranker, covered on what-a-reranker-does-after-first-retrieval.

Pattern C: Map, then reduce

Process the document section by section, then combine the results. For summaries, research on book-length texts gives a useful warning. Chang and colleagues (ICLR 2024) studied GPT-4 summaries of 100 recently published books longer than 100K tokens, using two workflows: "hierarchically merging chunk-level summaries" and "incrementally updating a running summary" 17(https://arxiv.org/abs/2310.00785). From 1,193 human annotations they identified eight common types of coherence error, including entity omission, event omission and "causal omissions," where "A reason or motivation is missing" 17(https://arxiv.org/abs/2310.00785). They found hierarchical merging "generally results in more coherent summaries but reduced level of detail compared to incremental updating," and that "increasing the chunk size does not improve hierarchical merging" 17(https://arxiv.org/abs/2310.00785). These are observed results for 2023 models on fiction, but the general point carries: each merge step is a place where details disappear. Keep section references in every intermediate summary so a reader can trace a claim back.

Pattern D: Long context plus structure

If you do paste a whole document, help the model: put the document first and the question last, label sections, include page or section numbers in the text, and ask for quotes with locations before the answer 5(https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices). Then check the quotes against the source.

Pattern E: Manage growing conversations

For long chats and agents, the window fills over time. Anthropic documents server-side "compaction," which "replaces the older turns of a conversation with a summary that Claude writes on the server," keeping the conversation inside the window and keeping "the active context small, because response quality degrades as a conversation grows"; both compaction modes are described as beta 4(https://platform.claude.com/docs/en/build-with-claude/compaction). OpenAI's conversation guide points to its own compaction guide 8(https://developers.openai.com/api/docs/guides/conversation-state). Compaction is summarization, so it inherits summarization's risk: the summary may drop the one instruction or number a later turn needs. Anthropic's own options include keeping recent turns "word for word" and writing your own summarization prompt "when the default summary drops something a later turn needs" 4(https://platform.claude.com/docs/en/build-with-claude/compaction).

8. How to test your own setup

Provider claims and benchmarks describe other people's documents. A short test on yours is worth more. The method below adapts Lost in the Middle's design 13(https://arxiv.org/abs/2307.03172) and RULER's point that single-needle tests flatter models 14(https://arxiv.org/abs/2404.06654). It is an editorial suggestion.

  1. Pick a real document of the size you plan to use.
  2. Plant known facts at several positions: near the start, at 25%, 50%, 75%, and near the end. Use facts the model cannot know from training, such as an invented inspection ID or a made-up figure in a clearly labeled test copy.
  3. Ask single-fact questions about each, and record accuracy by position.
  4. Ask harder questions that need two facts from different places, or a count across the whole document ("how many sections mention a deadline?"). RULER's aggregation tasks are proxies for this kind of question 14(https://arxiv.org/abs/2404.06654).
  5. Repeat with the context shrunk: send only the relevant chapter. If accuracy jumps, the long context was costing you.
  6. Log the stop reason and token usage for every run 2(https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons).
  7. Re-run after any model change, including a tokenizer change that alters counts 3(https://platform.claude.com/docs/en/build-with-claude/token-counting).

Hypothetical result table. Imagine 20 planted facts, four at each of five positions, run five times each (100 questions in total). A result such as 19/20 correct at the start, 15/20 at 25%, 12/20 at the middle, 16/20 at 75% and 20/20 at the end would total 82/100 correct, and would show a U-shape worth designing around. These numbers are invented to show the arithmetic and the shape to look for; your results may be flat, or worse.

9. Worked example: a long policy manual (hypothetical)

A regional beekeeping association keeps a 420-page operations manual. A volunteer wants an assistant that answers members' questions from it.

  • Step 1, count. The manual counts at roughly 310,000 tokens on the chosen model. It fits within a 1M-token window with room to spare.
  • Step 2, test. Following section 8, the volunteer plants ten test facts. Questions about the first and last chapters are answered correctly every time; two of four questions about a fee table in chapter 9, near the middle, get the fee from an older table in chapter 3 instead.
  • Step 3, redesign. The volunteer switches to retrieval: index the manual by section, retrieve the top five sections for each question, put them before the question, and require the answer to quote the section number.
  • Step 4, re-test. The fee questions now come back with the right table and a citation a member can check. A new failure appears: one question about an exception in a footnote misses it because the footnote was indexed separately. That becomes a chunking fix.

This example is invented. It shows the typical arc: whole-document prompting works for easy questions, fails quietly on some middle-of-document details, and retrieval trades that failure for different ones that are easier to see.

10. Common misconceptions

"If it fits, the model read it." The model processed it, but providers and studies report degraded recall as context grows, and position effects in tested models 1(https://platform.claude.com/docs/en/build-with-claude/context-windows) 13(https://arxiv.org/abs/2307.03172).

"A bigger window means a smarter model." Lost in the Middle found extended-context versions performed nearly identically to their shorter-context counterparts on the same tasks 13(https://arxiv.org/abs/2307.03172). RULER found effective length below claimed length for most tested models 14(https://arxiv.org/abs/2404.06654).

"The window is how much the model remembers about me." It is per request. Apps decide what to resend. Some drop old turns on a first-in, first-out basis 1(https://platform.claude.com/docs/en/build-with-claude/context-windows).

"Caching frees up space." Caching changes price, not whether the tokens count 1(https://platform.claude.com/docs/en/build-with-claude/context-windows).

"An error will tell me if I went over." Sometimes. Depending on settings, the earliest conversation items may be dropped, output may be capped, or a response may stop with a context-limit reason that your code has to check 9(https://developers.openai.com/api/reference/resources/responses/methods/create) 10(https://ai.google.dev/gemini-api/docs/long-context) 2(https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons).

"Long context makes retrieval obsolete." Google's page argues long context invites "providing all relevant information upfront" 10(https://ai.google.dev/gemini-api/docs/long-context), while Anthropic's argues for "the smallest possible set of high-signal tokens" 6(https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents). Both are vendor positions. Cost matters too: Google notes you "have to pay the input token cost every time you send that query" 10(https://ai.google.dev/gemini-api/docs/long-context). Which approach is better depends on the document, the question and the budget, and only testing settles it.

11. FAQ

How many pages fit in a 1M-token window? It depends on the text and the tokenizer. Google's rough figure of 60–80 English words per 100 tokens 12(https://ai.google.dev/gemini-api/docs/tokens) would put 1M tokens at very roughly 600,000–800,000 words of plain English prose for its models. Tables, numbers, code and other languages lower that. Count your actual file.

Does the answer really count toward the limit? Yes, at all three providers checked, though Google described earlier Gemini models as having a separate output budget 1(https://platform.claude.com/docs/en/build-with-claude/context-windows) 8(https://developers.openai.com/api/docs/guides/conversation-state) 10(https://ai.google.dev/gemini-api/docs/long-context).

Do images and PDFs use the window? Yes. Google gives per-image and per-second token costs 12(https://ai.google.dev/gemini-api/docs/tokens); Anthropic caps images and PDF pages per request 1(https://platform.claude.com/docs/en/build-with-claude/context-windows).

Why did my long chat suddenly forget the instructions? Possible causes include the app dropping early turns to fit the window, an API truncation setting that drops items "from the beginning of the conversation" 9(https://developers.openai.com/api/reference/resources/responses/methods/create), or a compaction summary that left them out 4(https://platform.claude.com/docs/en/build-with-claude/compaction). Restate key instructions, or start a new conversation with a clean summary.

Is the "lost in the middle" effect still real on current models? The 2023 study measured older models 13(https://arxiv.org/abs/2307.03172), and the 2024 RULER study found large differences between models 14(https://arxiv.org/abs/2404.06654). Current providers still warn about degraded recall in long contexts 1(https://platform.claude.com/docs/en/build-with-claude/context-windows). Test your own model and documents.

Should the question go before or after the document? Anthropic and Google both recommend after, for long inputs 5(https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices) 10(https://ai.google.dev/gemini-api/docs/long-context). Lost in the Middle found putting it both before and after helped key-value lookup but barely changed multi-document QA 13(https://arxiv.org/abs/2307.03172).

12. Limits of this page

  • Dated figures. Every limit in sections 3 and 4 is as documented on 27 November 2026. Model lineups and limits change frequently.
  • No tests run. This page reports documentation and published research. It did not send requests to any model to confirm limits or overflow behavior.
  • Older research models. The quality studies tested models from 2023 and 2024. Their results show what can go wrong and how to test, not how current models score.
  • Vendor claims are labeled. Figures such as "up to 30 percent" 5(https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices) and "up to 99% accuracy" 10(https://ai.google.dev/gemini-api/docs/long-context) come from providers describing their own products.

13. Reader takeaway

The context window is the token budget for one request: instructions, conversation, tool definitions, documents and the answer all draw from it. As of 27 November 2026, the flagship models documented by Anthropic, OpenAI and Google list windows of roughly a million tokens, but the exact figure, the output cap and the overflow behavior differ by provider and model.

Staying under the limit avoids errors. It does not guarantee that a fact on page 450 gets the same attention as one on page 2. Count tokens with the provider's tool, leave room for the answer, check the stop reason, send what is relevant rather than everything, put the question after the material, ask for quotes with locations, and test with planted facts at different positions before trusting a long-document workflow.

Correction note

  • The previous version of this page described the context window as "a critical component of our apiary platform" that aggregates "diverse data streams," builds a "knowledge graph," and supports "agent-human collaboration." None of that is what the term means. In language models, the context window is the token limit for a single request. That content has been removed.
  • The previous page's "Architecture" (data ingestion layer, knowledge graph engine) and "Applications" (pollinator health, climate mitigation) sections described no real system and have been removed.
  • The previous page cited no sources. This version cites provider documentation checked on 27 November 2026 and peer-reviewed or conference research, and labels vendor claims.
  • Grok's draft cited "a 1.05M-token context window and 128K max output for its listed GPT-6 models" at OpenAI; the 27 November 2026 models page still shows those figures for four listed models (GPT-6.2 Astra, GPT-6.2 Sol, GPT-6.1 Terra, GPT-6 Luna), and this page names them.

Related reading on Apiary

  • why-token-counts-differ-from-word-counts
  • wiki-retrieval-augmented-generation
  • how-chunk-boundaries-cause-retrieval-to-miss-context
  • what-a-reranker-does-after-first-retrieval
  • wiki-knowledge-cutoff
  • rate-limit-vs-spending-or-daily-limit

Sources

Last checked 27 November 2026. Numbered citations in the text link to these sources.

[1] Anthropic. "Context windows." Claude API documentation. Accessed 27 November 2026. Read source

[2] Anthropic. "Stop reasons and fallback." Claude API documentation. Accessed 27 November 2026. Read source

[3] Anthropic. "Token counting." Claude API documentation. Accessed 27 November 2026. Read source

[4] Anthropic. "Compaction overview." Claude API documentation. Accessed 27 November 2026. Read source

[5] Anthropic. "Prompting best practices" (section "Long context prompting"). Claude API documentation. Accessed 27 November 2026. Read source

[6] Anthropic Applied AI team. "Effective context engineering for AI agents." Anthropic Engineering, 29 September 2025. Read source

[7] OpenAI. "Models." OpenAI API documentation. Accessed 27 November 2026. Read source

[8] OpenAI. "Conversation state" (section "Managing the context window"). OpenAI API documentation. Accessed 27 November 2026. Read source

[9] OpenAI. "Create a model response" (Responses API reference, truncation). Accessed 27 November 2026. Read source

[10] Google. "Long context." Gemini API documentation. Accessed 27 November 2026. Read source

[11] Google. "Models." Gemini API documentation. Accessed 27 November 2026. Read source

[12] Google. "Understand and count tokens." Gemini API documentation. Accessed 27 November 2026. Read source

[13] Liu, Nelson F., Kevin Lin, John Hewitt, Ashwin Paranjape, Michele Bevilacqua, Fabio Petroni, and Percy Liang. "Lost in the Middle: How Language Models Use Long Contexts." Transactions of the Association for Computational Linguistics, 2023; arXiv:2307.03172v3, 20 November 2023 (full PDF read). Read source

[14] Hsieh, Cheng-Ping, Simeng Sun, Samuel Kriman, Shantanu Acharya, Dima Rekesh, Fei Jia, Yang Zhang, and Boris Ginsburg. "RULER: What's the Real Context Size of Your Long-Context Language Models?" COLM 2024; arXiv:2404.06654v3, 6 August 2024 (full PDF read). Read source

[15] Vaswani, Ashish, et al. "Attention Is All You Need." NeurIPS 2017; arXiv:1706.03762 (full PDF read). Read source

[16] Press, Ofir, Noah A. Smith, and Mike Lewis. "Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation." ICLR 2022; arXiv:2108.12409 (full PDF read). Read source

[17] Chang, Yapei, Kyle Lo, Tanya Goyal, and Mohit Iyyer. "BooookScore: A Systematic Exploration of Book-Length Summarization in the Era of LLMs." ICLR 2024; arXiv:2310.00785v4 (full PDF read). Read source

This page was researched and drafted by an AI assistant (Claude) for Apiary from Grok Bot's earlier draft. Sources were opened and read on 27 November 2026. It has not been reviewed by a human expert and is not founder-verified. Status: candidate.

Frequently asked
What is Context Windows and Long Documents: What the Limit Means in Practice about?
A language model's context window is the total amount of text, measured in tokens, that the model can take into account in a single request. Anthropic's…
What should you know about a budget, not a memory of you?
The context window is per request. When you send a message in a chat app, the app typically sends the whole visible conversation again, plus whatever system instructions it uses. Anthropic's diagram describes "progressive token accumulation": each user message and each assistant response is added to the window as the…
What should you know about tokens, not words or pages?
Limits are stated in tokens, the units a tokenizer cuts text into. Google's documentation gives a rough rule for its models: a token is "about 4 characters" and "100 tokens is equal to about 60-80 English words" 12 (https://ai.google.dev/gemini-api/docs/tokens). That ratio is for English prose with one tokenizer.…
What should you know about not only text?
Images, PDFs, audio and video also become tokens. Google's token guide says images up to 384 pixels in both dimensions "count as 258 tokens," larger images are tiled into 768×768 pixel tiles of 258 tokens each, video costs "263 tokens per second" for static processing, and audio "32 tokens per second" 12…
What should you know about 2. What counts toward the window?
Anthropic's documentation is explicit: "Everything in the request counts toward the context window: the system prompt, every message in messages (including tool results, images, and documents), and your tool definitions. The output Claude generates for the turn, including its extended thinking, counts too" 1…
References & sources
  1. Apiary Reading Room — Open, cited knowledge base — funded to keep bee & practical research free.
From the Apiary Reading Room. Opinion & editorial — not financial advice. We don't overclaim.
More from the Reading Room