Software Engineeringunpacked

The LLM context window, explained with Claude: what counts, why more isn't better, and how to manage it

An LLM's context window is everything the model can see while it writes a response: the system prompt, the conversation, tool definitions, tool results, documents, and the response itself. Current Claude models have a 1M-token window, but more context is not automatically better: as the token count grows, accuracy and recall degrade. Managing what goes in matters as much as how much fits.

What is an LLM context window?

Anthropic's docs define the context window as "all the text a language model can reference when generating a response, including the response itself". It is the model's working memory for one request, not the data it was trained on, and it is measured in tokens.

Everything in the request counts: the system prompt, every message (including tool results, images and documents), your tool definitions, and the output Claude generates for that turn, thinking included. Each response reports what it used in its usage field, and the token counting API estimates a request before you send it.

Why a bigger context window isn't automatically better

The docs put it plainly: "more context isn't automatically better. As token count grows, accuracy and recall degrade, a phenomenon known as context rot." A detail buried in the middle of a long conversation is easier to miss than the same detail near the start or the end.

So the skill is curating the window, not filling it:

Claude context window sizes

Models Context window Notes
Claude Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.1, Mythos 5.1 and other current models 1M tokens Default, no beta header; up to 128k output tokens per request
Older models, such as Claude Sonnet 4.5 200k tokens

A request can also include up to 600 images or PDF pages on the 1M models, so very large media can hit request-size limits before token limits.

How conversations and agents fill the window

The Messages API is stateless, so each turn resends the whole history: every user message, every reply, every tool result. In an agent loop, tool outputs pile up fastest: one verbose search result can cost thousands of tokens and stays in every later request. With thinking, thinking tokens count toward the window and are billed as output; whether earlier thinking blocks stay in later turns depends on the model.

What happens when you hit the limit

Managing context in long conversations and agents

Tool What it does
Server-side compaction (beta, Claude 4.6 and later) Summarizes earlier parts of the conversation on the server so it can continue past the limit
Context editing Clears old tool results or old thinking blocks
Subagents Keep exploration in a separate window; only the summary comes back
Files and scratchpads Long tasks write progress and key facts to disk, so a fresh session can recover them

Summaries lose detail: an exact amount or a booking ID can become "a refund was discussed". Persistent rules belong somewhere that is re-read every time, such as CLAUDE.md for Claude Code and Agent SDK sessions, not only in the first message.

Context on the Claude Certified Architect exam

Domain 5, Context Management & Reliability, is 15% of the CCAR-F exam. It covers preserving critical facts across long conversations, trimming verbose tool results, the "lost in the middle" effect, delegating exploration to subagents to protect the main context, and what summaries keep and lose. The usual trap: answering a context problem with "use a bigger window" when the fix is to curate what goes in.

More in all articles.

Sources: Context windows; Compaction; Context editing; Effective context engineering for AI agents; Claude Certified Architect Foundations exam guide v1.0, domain 5.

FAQ

What is a context window in an LLM?

All the text the model can reference when generating a response, including the response itself. It works like the model's working memory, separate from the data it was trained on, and is measured in tokens.

How big is Claude's context window?

1M tokens on the current models, including Claude Opus 5.5, Sonnet 5.5 and Haiku 5.5, with no beta header needed; a single request can generate up to 128k output tokens. Older models, such as Claude Sonnet 4.5, have 200k.

What happens when you exceed the context window?

If the input alone is too long, the API returns a 400 prompt-is-too-long error. On Claude 4.5 models and newer, if the output then runs into the limit, the response stops with stop_reason model_context_window_exceeded.

What is context rot?

The drop in accuracy and recall as the number of tokens in context grows. It is why curating what goes into the context matters as much as the size of the window.