# What is a context window? Sizes by model in 2026, and limits

URL: https://sdclabs.com/glossary/context-window/

> A context window is how many tokens an LLM can handle per request. What counts toward it, 2026 sizes for Claude, GPT and Gemini, and what happens on overflow.

# What is a context window?

[Mykhailo Poliarush](https://sdclabs.com/author/poliarush/) 2026-11-27

Definition

A context window is the maximum number of tokens a language model can handle in one request, counting the system prompt, messages, tool definitions, tool results and the response it writes. Input beyond it is rejected or has to be dropped. In November 2026, flagship models from Anthropic, OpenAI and Google offer about 1 million tokens.

## What counts toward the context window?

Everything in the request, plus the answer. Anthropic's [context windows documentation](https://platform.claude.com/docs/en/build-with-claude/context-windows) lists the parts:

- the system prompt;
- every message, including tool results, images and documents;
- the tool definitions;
- the output the model generates for the turn, including extended thinking.

Two details catch teams out. Cached prompt prefixes still occupy the window: caching changes what you pay for those tokens, not whether they count. And each API response reports what the request used in its usage field, so you can measure instead of guessing. To check a request before you send it, use a token counting endpoint rather than a word count, because tokens are not words.

The same page calls the window the model's "working memory." It is separate from the training data, which the model learned from once and cannot see as text.

## How big are context windows in 2026?

Flagship models from Anthropic, OpenAI and Google now sit at about 1 million tokens. Sizes from each provider's model documentation, checked on 2026-11-19:

| Provider | Models | Context window | Max output per request | Source |
|---|---|---|---|---|
| Anthropic | Claude Opus 5.5, Sonnet 5.5, Haiku 5.5 and other current models | 1M tokens | 128k tokens | [Claude docs](https://platform.claude.com/docs/en/build-with-claude/context-windows) |
| Anthropic | Claude Sonnet 4.5 (deprecated) and other older models | 200k tokens | Not listed on that page | Claude docs |
| OpenAI | GPT-6.2 Astra, GPT-6.2 Sol, GPT-6.1 Terra, GPT-6 Luna | 1.05M tokens | 128K tokens | [OpenAI models](https://developers.openai.com/api/docs/models) |
| Google | Gemini 4 models (Carbon, Neon, Hydrogen, Argon) | 1M tokens | Listed as "64K / 1M" | [Gemini models](https://aistudio.google.com/docs/models) |

These numbers move with every model release, so treat the table as a snapshot and check the provider page before you design around a limit.

Size and price are linked. On Claude, 1M is the default with no beta header and is billed at standard rates, except on Claude Haiku 5.5, where prompts over 100,000 tokens cost more. A request can also hit a different limit first: up to 600 images or PDF pages per request on 1M-token Claude models, and 100 on the 200k ones.

## What happens when a request is too big?

The rules differ by case. On the Claude API:

| Case | What happens |
|---|---|
| The input alone is larger than the window | The API rejects it with a 400 invalid_request_error ("prompt is too long") |
| Input fits, but input plus max_tokens is larger | Claude 4.5 and newer accept the request; output stops with stop_reason: "model_context_window_exceeded" if it reaches the limit |
| The same case on older models | A validation error, unless you send the opt-in beta header |

Chat apps hide this from you. The docs note that interfaces such as claude.ai can drop the oldest turns on a "first in, first out" basis. An API integration has to make that choice in its own code.

## Is a bigger context window always better?

No. The Claude docs say it directly: "more context isn't automatically better", because accuracy and recall drop as the token count grows.

Two 2026 studies show how far apart the advertised size and the usable size can be:

- **More input, lower accuracy.** A [February 2026 paper](https://arxiv.org/abs/2602.14188) tested Grok-4, GPT-4, Gemini 2.5 and GPT-5 on classifying social media posts in bulk. Past 5,000 posts (about 70,000 tokens), every model degraded significantly, and accuracy fell to around 50 to 53% at 20,000 posts. The same authors report that the "lost in the middle" problem is largely resolved in newer models.
- **Dense input fails sooner.** A [June 2026 paper](https://arxiv.org/abs/2606.06203) held length fixed at about 12,000 tokens and raised the density of distinct information instead. Open-weight models from 9B to 685B parameters that were near-perfect on sparse inputs dropped below a 60% retrieval score on dense ones.

Both test narrow tasks, so read them as warnings to measure your own case, not as rates you will see.

So a large window is room, not a strategy. What you put in it is [context engineering](https://sdclabs.com/glossary/context-engineering/) .

## Context window vs training data vs memory

|   | Context window | Training data | Agent memory |
|---|---|---|---|
| What it is | Tokens sent with this request | Text the model learned from before release | Notes or records stored outside the model |
| Who controls it | You, per request | The model provider | Your application |
| When it changes | Every call | Only with a new model | When the agent or your code writes to it |
| Size limit | The model's window | None you can use directly | Your storage |

Memory only helps when it is loaded back into the window. Our guide on [how to build AI agents](https://sdclabs.com/blog/how-to-build-ai-agents/) covers when to add it.

## Example: check a request before you send it

This script applies the overflow rules above to three requests. Feed it real input_tokens from a token counting call.

# window.py: check a request against a context window before you send it. # Sizes and overflow rules from Anthropic's context windows page (checked 2026-11-19). # Get input_tokens from the token counting API, not from a word count. WINDOWS = {"claude-opus-5-5": 1_000_000, "claude-sonnet-4-5": 200_000} def check(model, input_tokens, max_tokens): window = WINDOWS[model] if input_tokens > window: return "rejected: 400 prompt is too long" if input_tokens + max_tokens > window: # Claude 4.5 and newer accept this return f"accepted, but output may stop early ({window - input_tokens:,} tokens left)" return f"fits ({window - input_tokens - max_tokens:,} tokens spare)" requests = [ ("claude-opus-5-5", 180_000, 64_000), # long agent session ("claude-sonnet-4-5", 180_000, 64_000), # same request, smaller window ("claude-sonnet-4-5", 240_000, 8_000), # input alone is too big ] for model, inp, out in requests: print(f"{model:18} in={inp:>7,} max_out={out:>6,} -> {check(model, inp, out)}")
Output under Python 3.11:

claude-opus-5-5 in=180,000 max_out=64,000 -> fits (756,000 tokens spare) claude-sonnet-4-5 in=180,000 max_out=64,000 -> accepted, but output may stop early (20,000 tokens left) claude-sonnet-4-5 in=240,000 max_out= 8,000 -> rejected: 400 prompt is too long
The second line is the one to watch. The request goes through, and the answer can end mid-sentence 20,000 tokens later. Check stop_reason on every response.

## What should you check before relying on a large window?

1. **Count, do not estimate.** Use the provider's token counting and usage fields.
1. **Reserve output room.** Leave space for max_tokens, and thinking if it is on.
1. **Handle the stop reason.** Treat a window-exceeded stop as an incomplete answer, not a result.
1. **Test recall at your real input size.** A model that works at 20k tokens may miss facts at 400k.
1. **Plan for long runs.** Agents that outgrow the window need compaction or a handoff, usually built into the [agent harness](https://sdclabs.com/glossary/agent-harness/) .

SDCLabs builds [AI agents](https://sdclabs.com/services/ai-agents/) with a test set of real examples, evals that score every change, and traces and cost dashboards for every run.

## Sources

1. [Context windows](https://platform.claude.com/docs/en/build-with-claude/context-windows) , Anthropic, 2026-11-19
1. [Models](https://developers.openai.com/api/docs/models) , OpenAI, 2026-11-19
1. [Models](https://aistudio.google.com/docs/models) , Google, 2026-11-19
1. [GPT-5 vs Other LLMs in Long Short-Context Performance (arXiv 2602.14188)](https://arxiv.org/abs/2602.14188) , Esmi et al., 2026-02-15
1. [Dense Contexts Are Hard Contexts: Lexical Density Limits Effective Context in LLMs (arXiv 2606.06203)](https://arxiv.org/abs/2606.06203) , Dettori et al., 2026-06-04

## Frequently asked questions

### How many words fit in a context window?

There is no fixed ratio, because tokens are not words and each provider uses its own tokenizer. Count tokens with the provider's token counting endpoint, or read the usage field of a real response.

### Does the context window include the model's answer?

Yes. The output, including any thinking tokens, counts toward the same limit as the input, which is why you need to leave room for max_tokens.

### Does a model remember past chats outside the context window?

Not by itself. Anything the model should use has to be in the current request. Apps that seem to remember store notes elsewhere and load them back into the window.

### Which model has the largest context window?

On 2026-11-19, OpenAI listed 1.05M tokens for its four flagship GPT-6 models, and Anthropic and Google listed 1M for current Claude and Gemini 4 models. Check the provider pages, because sizes change with each release.

Services

- [AI agents](https://sdclabs.com/services/ai-agents/)
- [Generative AI](https://sdclabs.com/services/generative-ai/)

Read next

- [How to build AI agents that still work after the demo](https://sdclabs.com/blog/how-to-build-ai-agents/)
- [What is AI agent development, and should you build or buy?](https://sdclabs.com/blog/what-is-ai-agent-development/)

Related terms

- [Context engineering](https://sdclabs.com/glossary/context-engineering/)
- [Agent harness](https://sdclabs.com/glossary/agent-harness/)
- [Agentic RAG](https://sdclabs.com/glossary/agentic-rag/)

[Mykhailo Poliarush](https://sdclabs.com/author/poliarush/) Founder and CEOLeads SDCLabs, an AI development company founded in Krakow in 2011.[LinkedIn](https://www.linkedin.com/in/poliarush/) [GitHub](https://github.com/poliarush)

## Building with AI agents? Talk to an engineer.

[Start a project](https://sdclabs.com/contact/) [Book a call with the CEO](https://calendly.com/sdclabs/60min)
