Long context
Put the whole document set into the window and ask questions over it.
- No index to build or keep fresh
- Sees cross-document links a search might miss
- Strong at finding one fact
- Every question pays for every token
Everything a model can consider when it writes a reply — instructions, history, documents, tools and the reply itself — has to fit in one window.
A language model has no memory between requests. Each call sends it a block of tokens, and the context window is the most that block can hold. This guide explains what a token is, what counts toward the window, how big windows have become, why models still miss facts placed in the middle of long inputs, and how to choose between loading everything and retrieving only what a step needs.
Updated · 9 sources
A context window is the amount of text, measured in tokens, that a language model can take into account at once — the input it is given plus the output it writes. Claude’s documentation calls it the model’s “working memory”, distinct from the data it was trained on. Anything outside the context window is invisible to the model on that call.
Models read tokens — word pieces, punctuation, and fixed-size patches of images and audio. Each model family has its own tokenizer, so the same text is a slightly different count on each.
count_tokens takes the same input as a real request — system prompt, tools, images, PDFs — and returns an estimate.Output shares the window. The reply is written into the same window as the input. A request that fills the window with input leaves no room for the answer — Claude returns a “prompt is too long” error when the input alone is over.
In under four years — May 2020 to February 2024 — the largest windows grew about 490-fold (1,000,000 ÷ 2,048, our arithmetic). What fits changed from a few pages to a code base — but, as the next section shows, what a model can reliably use did not grow at the same rate.
In 2023 Liu and colleagues moved one relevant document through a stack of irrelevant ones and measured accuracy at each position. The result was a U-shaped curve: models used facts at the start and end of the input well, and facts in the middle badly.
What helps. Put the material that matters at the start or right beside the question. The paper found that repeating the question before and after the data made a simple lookup task near-perfect — though it changed little on harder question answering. Past about 20 retrieved documents, adding more barely moved accuracy.
A million-token window tempts teams to skip retrieval and send everything. Sometimes that is right. The trade-off is cost per question, freshness, permissions and recall on many facts at once.
Put the whole document set into the window and ask questions over it.
Search a store for the passages this question needs and send only those.
How large is the material, and how often is it asked about?
Each turn adds the person’s message, the reply and every tool result. Left alone, the window fills; managed, an agent can work far beyond one window’s worth of tokens.
Estimate tokens before each call; read the usage after it.
Give instructions, history, retrieval and tools each an allowance.
Stable blocks first so they cache; key facts near the question.
Drop old tool results once they have been used.
Near the limit, summarise and continue in a fresh window.
Write what must survive to a store outside the window.
On Botminds the context window is a budget the platform manages for every agent on every turn — split into tiers, filled by priority, and open to inspection before a model reads it.
Read how the budget works in context engineering on Botminds, and how an agent’s model, instructions and tools fit together in the anatomy of an agent.
A context window is the number of tokens a language model can consider at once: the system prompt, the conversation, any documents and tool results, and the reply it writes. Text outside the context window is invisible to the model on that call.
If the input alone is too long, the request is refused — Claude returns a “prompt is too long” error. If the reply runs into the end of the window, generation stops. Chat apps avoid both by dropping, summarising or compacting older turns.
Using Google’s rule of thumb of 60–80 English words per 100 tokens, a million tokens is roughly 600,000 to 800,000 words — Google’s examples are eight average-length novels or 50,000 lines of code.
No. A bigger window lets more fit, but recall falls as inputs grow — Claude’s documentation calls this context rot, and the Lost in the Middle paper showed facts in the middle of long inputs are used worst. Choosing what goes in still matters.
It is the finding, from Liu et al. (2023), that language models use information at the beginning and end of a long input much better than information in the middle, giving a U-shaped accuracy curve as the relevant passage moves through the input.
Yes. The reply is written into the same window as the input, and on reasoning models the thinking tokens count too. Leave room for the answer when you fill the window.
Use long context when the material fits and is read once or a few times. Use retrieval when the corpus is larger than any window, changes often, or must be filtered by who is asking — and to keep the cost of each question low.
Yes. They are converted to tokens too. On Gemini, a small image costs 258 tokens and audio about 32 tokens per second; other providers count differently, so use the provider’s token counter.
Bring one process and its documents. We’ll show you the agents, the controls and the record, running on your data.