The context window is the model's working memory.
A context window is the maximum number of tokens a language model can take in and produce in one request: your instructions, the conversation so far, any documents you paste, and the reply, all counted together. Everything outside it does not exist for the model. Larger windows help, but they cost more, get slower and still lose detail in the middle, which is why retrieval still matters.
- Measured in
- Tokens, roughly three-quarters of a word each
- Counts
- System prompt, history, documents, tools, the reply
- Bigger is not free
- Cost, latency, lost-in-the-middle
- Pair with
- Retrieval and prompt caching
- 5production AI apps
- 14engineers led
- 200+students mentored
Questions students ask
The context window questions searched most, answered plainly.
What is context window?
The context window is the span of text a model can attend to in a single request. Think of it as a desk: whatever is on the desk the model can read and reason about; anything in the filing cabinet it cannot see unless you put it on the desk. The size is fixed per model and measured in tokens. It includes everything you send and everything the model writes back. When the total would exceed the limit, either the request is rejected or the oldest part of the conversation is dropped, depending on the product, and the model loses whatever was removed.
What is context window in LLM?
For a large language model the context window is a hard architectural limit. Transformers process a sequence of tokens and compute attention between every pair, so the maximum sequence length is set at training time and enforced at inference. Modern models have windows from tens of thousands to over a million tokens. Within the window the model can reference any earlier token, which is why it can answer about a document you pasted. Beyond the window it has no memory at all; a chat that 'remembers' earlier turns is simply resending them inside the window each time.
How does context window work in LLM?
Every request is assembled into one token sequence: the system prompt, any tool definitions, the conversation turns, attached documents, and finally the model's reply, generated one token at a time while attending to everything before it. Positional encodings tell the model where each token sits. As the sequence grows, attention cost grows with it, so long prompts are slower and more expensive, and studies have shown models attend less reliably to material in the middle of a very long prompt than to the start and end. Keeping the relevant material short and near the question is still the best practice.
What are context window tokens?
Tokens are the pieces a model's tokeniser splits text into: common words are one token, longer or rarer words become two or three, and punctuation, spaces and code symbols get their own. In English a token is about three-quarters of a word, so a thousand tokens is roughly 750 words; Hindi and other scripts often cost more tokens per word. The context window limit is in tokens, not characters or words, and the reply counts too. Every provider offers a token counter; use it when you are deciding how much of a document fits.
What is context window size?
Context window size is the model's maximum token count per request, published on each provider's model page. Sizes have grown from a few thousand tokens in 2022 to hundreds of thousands and, for some models, a million or more. Two numbers matter: the input limit and the maximum output length, which is usually much smaller. A model with a very large window may still cap its reply at a few thousand tokens. Also check what you are billed for: a large window is only useful if you can afford to fill it on every call.
What is a long context window?
A long context window usually means hundreds of thousands of tokens or more, enough to hold several books, a whole codebase or hours of transcripts in one request. It makes some tasks simple, such as asking a question about one long contract without building any retrieval. It does not remove the need for retrieval across a large corpus, because the corpus is still bigger than the window, because sending everything on every request is slow and expensive, and because accuracy on details buried in the middle of a huge prompt is measurably lower than on a short, focused prompt. Long context and RAG are complements.
What are context window limits?
- The hard limit: input plus output tokens cannot exceed the model's window; the request fails or is truncated.
- The output limit: a separate, smaller cap on how long a reply can be.
- The practical limit: cost per request grows with every token you send, so filling a large window on every message is expensive.
- The attention limit: recall of facts in the middle of very long prompts drops; put key material at the start or end.
- The product limit: chat apps may silently trim old turns, and coding tools manage the window by summarising earlier work.
What is context window in ChatGPT?
In ChatGPT the window is managed for you. The app keeps recent turns and any files you attached within the model's window, and when a long conversation would exceed it, older parts are dropped or compressed, which is why the assistant can forget something from early in a long chat. The underlying model's window depends on the model selected and on the plan. If precision over a long document matters, start a fresh chat for it, attach the file, and ask specific questions rather than relying on a long-running conversation.
What is context window in Claude?
Claude models offer large context windows, and the exact size for each model is published on Anthropic's model page. In the Claude app, attached files and pasted text count against that window along with the conversation. Through the API you control what goes into the window on each call, which is where prompt caching becomes valuable: a long, stable prefix such as a document set or a system prompt can be cached and reused across requests at a lower cost, so a large window stops being a large bill. Check the current model documentation before assuming a size.
What does context window mean in Claude Code?
In Claude Code, the context window holds the conversation with the agent plus everything it has read and done: file contents, command output, tool results and its own reasoning. As a long session grows, the tool compacts earlier material into a summary to make room, so older details are kept in condensed form rather than verbatim. Practically, that means you should keep sessions focused on one task, let the agent read only the files it needs, and start a new session for a new piece of work. The window is the agent's working memory; what you put in it shapes what it does.
Manage the window
Four habits that keep cost down and accuracy up.
- 01
Count before you send
Use the provider's token counter; know what a page, a file and a conversation cost.
- 02
Retrieve, don't paste
For a corpus, index it and send only the relevant passages per question.
- 03
Cache the stable prefix
Put the system prompt and fixed documents first and use prompt caching.
- 04
Keep the question close
Place the most relevant material right before the question; trim what is not needed.
In the room
Where these systems get explained to students.


Read next
What fills the window and how to keep it small.
Paying for a window you don't need?
I can look at what your prompts carry and cut cost without losing accuracy.

