Sign inStart free
§Guide

What is a context window, and why do long conversations get worse?

AgentPrep guide cover: What is a context window, and why do long conversations get worse?

A context window is all the text a language model can reference when it generates a response — including the response itself. It isn't the same as what the model was trained on; think of it as working memory for this one conversation, not general knowledge.

Its size matters less than what's inside it: more context isn't automatically better, because accuracy and recall degrade as token count grows, a pattern known as context rot. Below: what fills the window without you noticing, how big it actually is depending on the model, what happens when you go over it, and what gets managed for you automatically.

What actually fills the context window

Every message you send and every reply the model gives accumulates inside the window as a conversation continues — earlier turns aren't summarized away on their own, they're preserved in full.

Why more context isn't automatically better

This is the part that surprises most people, and it's the reason this page exists: a bigger window is not simply a bigger advantage.

The practical consequence is that curating what's in context matters just as much as how much space is available. A window with plenty of room to spare can still be full of the wrong thing.

“More context isn't automatically better. As token count grows, accuracy and recall degrade, a phenomenon known as context rot.”

How big it is, and what counts against it

Size depends on the model. Claude Opus 5, Opus 4.8, Opus 4.7, Opus 4.6, Sonnet 5 and Sonnet 4.6 all have a 1M-token context window on the Claude API, Amazon Bedrock, Google Cloud and Microsoft Foundry — as do Claude Fable 5 and Mythos 5. Other models, including Claude Sonnet 4.5, have 200k.

In the 1M-token models, a single request can generate up to 128k tokens of output, and a request can include up to 600 images or PDF pages — 100 in the 200k models.

Every response reports exactly how much of the window it used, in a usage field. With prompt caching on, that input count splits into input_tokens, cache_read_input_tokens and cache_creation_input_tokens — and all three still count toward the window. Caching changes what those tokens cost you, not whether they take up space.

What happens when you go over it, and how it's managed for you

If the input alone is already bigger than the window, the API rejects the request outright with a 400 invalid_request_error saying the prompt is too long. In Claude 4.5 models and newer, it's less blunt: if input plus the max_tokens you asked for would exceed the window, the request is accepted anyway, and generation only stops if it actually reaches the limit, ending with stop_reason: “model_context_window_exceeded”.

There's also a token counting API for estimating how much of the window a request will use before you send it. And three things happen to manage the window for you, without being asked:

FAQ

What is a context window?

All the text a language model can reference when it generates a response, including the response itself — the system prompt, every prior message, tool results, tool definitions and the reply itself. It's different from the data the model was trained on; think of it as working memory for the current conversation, not general knowledge.

What is context rot?

The pattern behind why a bigger context window isn't automatically better: as token count grows, accuracy and recall degrade. It's why curating what's in context matters just as much as how much space is available.

How big is a context window, in tokens?

It depends on the model. Claude Opus 5, Opus 4.8, Opus 4.7, Opus 4.6, Sonnet 5, Sonnet 4.6, Fable 5 and Mythos 5 all have a 1M-token window on the Claude API, Amazon Bedrock, Google Cloud and Microsoft Foundry. Other models, including Claude Sonnet 4.5, have 200k.

What happens when a request exceeds the context window?

If the input alone is already bigger than the window, the API rejects the request with a 400 invalid_request_error. In Claude 4.5 models and newer, input plus max_tokens exceeding the window is accepted, and generation stops with stop_reason: “model_context_window_exceeded” only if it actually hits the limit.

Read next

Managing context is a skill you can practice

AgentPrep drills the craft this page describes — original scenario questions and mastery tracked per area, in full on Telegram. Free to start in your browser, no card.

Start free
Sources