In Plain Words
A model with a 1M-token context window does not get to read 1M tokens of your prompt. It reads whatever fits after everything else in the request has taken its share, and the reply it writes comes out of the same budget. OpenAI's docs put it plainly: the limit "includes input, output, and reasoning tokens."
Tokens are the chunks of text a model reads and writes. They are not words. Anthropic's model table puts 1M tokens at roughly 555,000 words on Claude's current tokenizer and 200k tokens at roughly 150,000 words.
Anthropic's context window docs call the window the model's "working memory", as opposed to the large corpus it was trained on. The model has no other view of your conversation. In a Messages API request, the input holds the whole earlier conversation plus the new message, and the model sees only what is inside the window on that one request.

How It Works
For one request to a chat model, the window fills in this order:
- The client assembles the request: the system prompt, the tool definitions, every earlier message (including tool results, images and documents) and the new user message. Anthropic's docs say all of it counts.
- Everything in it is split into tokens and read as input.
- The model generates its output, including any thinking, into the space that is left. A separate setting,
max_tokens, caps how long that output may be. - On the next turn the output joins the history and the whole request is sent again, so each turn starts fuller than the last.
What happens at the limit depends on who runs the model:
| Runtime | What happens at the limit |
|---|---|
| Claude API, input too long | 400 invalid_request_error ("prompt is too long") |
| Claude API, Claude 4.5 and newer, output reaches the limit | Generation stops with stop_reason: "model_context_window_exceeded" |
| OpenAI API | Tokens generated past the limit "may be truncated in API responses" |
| Ollama | The prompt is cut to fit num_ctx (default 4096 tokens) and the client gets no error |
| claude.ai chat | Can manage the window on a rolling "first in, first out" basis |
Ollama gives no sign on the client side: the prompt is cut and the response looks normal. We ran Ollama 0.40.16 on an Apple silicon Mac with a 1.5B chat model (SeaLLMs-v3-1.5B, Q4_K_M) and a 1,606-token prompt. Its first line read "The deploy password is PURPLE-FALCON-42. Remember it.", then came 120 lines of filler and the question. With num_ctx set to 512, the API returned a normal response and a wrong answer:
# num_ctx 512
{"num_ctx": 512, "prompt_eval_count": 258, "response": "The deploy password is: 1234567890.", "done_reason": "stop"}
# server log for that request
level=WARN source=llama_server.go:344 msg="truncating input prompt" limit=258 prompt=1606 keep=4 new=258
# num_ctx 4096
{"num_ctx": 4096, "prompt_eval_count": 1606, "response": "The deploy password is PURPLE-FALCON-42.", "done_reason": "stop"}SeaLLMs-v3-1.5B reports a training context of 131,072 tokens. The server log still said n_ctx_seq (512) < n_ctx_train (131072), because the window you get is whatever the runtime allocates, not the length the model was trained for. Ollama documents num_ctx and OLLAMA_CONTEXT_LENGTH for raising it.
To check fit before sending, Anthropic's token counting endpoint accepts the same inputs as a message request, is free to call, and returns an estimate:
curl https://api.anthropic.com/v1/messages/count_tokens \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "content-type: application/json" \
-H "anthropic-version: 2026-10-21" \
-d '{
"model": "claude-opus-5-5",
"system": "You are a scientist",
"messages": [{
"role": "user",
"content": "Hello, Claude"
}]
}'The docs show this response:
{ "input_tokens": 14 }Why It Matters
Agents fill the window faster than chat does, because tool definitions and tool results ride along on every turn. One measurement of GitHub's MCP server put its tool schemas at 55,000 tokens before the agent reads your prompt, more than a quarter of a 200k window. The AI harness decides what stays in the window each turn. A subagent does noisy work in a window of its own and hands back a summary. Agent skills load full instructions only when a task needs them, and Model Context Protocol servers add a schema for every tool they expose.
A bigger window is not a better one by default. Anthropic's docs say that "as token count grows, accuracy and recall degrade" and call it context rot. Chroma tested 18 models and found performance consistently degrades with increasing input length, even on simple tasks. The 2023 Lost in the Middle paper found that models do best when the relevant text sits at the beginning or end of the input, and that performance significantly degrades when it sits in the middle. Anthropic's context engineering guide treats context as "a finite resource with diminishing marginal returns", which is the case for curating what goes in rather than filling the window because it is there.
Two practical traps follow. Prompt caching lowers the price of a repeated prefix, but cached tokens "still occupy the context window". Token counts also change between models: Anthropic says the tokenizer introduced with Claude Opus 4.7 produces about 30 percent more tokens for the same text, so a prompt that fit on an older model can overflow on a newer one.
Common Confusions
| Term | What it is | How it differs |
|---|---|---|
| Context length, token limit | Other names for the same limit | No difference. IBM's explainer gives "context length" as another name for it, and OpenAI's docs call it a "max tokens number". |
Max output tokens (max_tokens) | A per-request cap on generated tokens | It sits inside the window. Claude Opus 5.5 has a 1M-token window and a 128K output cap. |
| Training data | The corpus the model learned from | Fixed at training time. The window is per request and holds only what you send. |
| Memory | Stored notes that outlive a session, such as files written by Claude's memory tool | Kept outside the window and read back into it on demand. |
| RAG (retrieval-augmented generation) | Retrieving relevant passages and appending them to the prompt | A way to choose what enters the window, not a substitute for it. |
| Prompt caching | A discount on a reused prompt prefix | Changes what cached tokens cost, not whether they count. |