D5 · Context & Reliability › Cluster 1 · Context Windows & Token Budgeting

1.1 · The Context Window (Sizes, 1M)

The finite working memory

CONCEPT One budget for everything the model reads and writes

The context window is all the text a model can reference when generating a response — including the response itself. Anthropic calls it the model's "working memory": it is not the training corpus, it's the finite space that holds this request. Everything counts toward it — the system prompt, every message in messages (tool results, images, documents included), your tool definitions, and the output Claude generates for the turn, extended thinking included.

🔑 The context window is a single shared budget: the growing message history and the reserved output draw from the same pool. Fill it with history and you starve the reply; reserve too much for the reply and you can't fit the history. 1.3 is where you learn to split it.

CONCEPT Current sizes — 1M is the default, not a beta

The 1M-token tier is now the default for the top models: no beta header, and long-context requests bill at standard pricing. The exam-relevant sizes:

ModelContext windowHow to enable
Opus 4.8 / 4.7 / 4.61M tokensDefault — no beta header
Sonnet 5 / Sonnet 4.61M tokensDefault — no beta header
Fable 5 / Mythos 51M tokens (up to 128K output)Default — no beta header
Sonnet 4.5 & other older models200K tokens—
Haiku 4.5200K tokens—
⚠️ Bigger is not automatically better. As token count grows, accuracy and recall degrade — Anthropic calls this context rot. Curating what is in context matters as much as how much space you have. A 1M window is headroom, not a license to dump everything in.
A single request can include up to 600 images or PDF pages (100 for 200K-context models) — but you may hit request size limits before the token limit on heavy documents.

DIAGRAM History + output share one window

flowchart TD W["Context window (e.g. 1M tokens)"] --> IN["INPUT phase"] W --> OUT["OUTPUT phase"] IN --> SYS["System prompt"] IN --> HIST["Message history
(grows every turn)"] IN --> TOOLS["Tool definitions"] OUT --> RESP["Reply + extended thinking
(reserved by max_tokens)"] HIST -.->|"grows toward"| RESP classDef ok fill:#d4edda,stroke:#28a745,color:#155724; classDef gate fill:#ffe8cc,stroke:#ff9f40,color:#9a4a0a; classDef bad fill:#f8d7da,stroke:#dc3545,color:#721c24; class W ok; class RESP gate; class HIST gate;

CODE The usage field reports what the request consumed

Every response tells you exactly how much of the window this turn used. With prompt caching the input count is split across three fields — all three count toward the window.

# Anthropic Python SDK
resp = client.messages.create(
    model="claude-opus-4-8",   # 1M context, default — no beta header
    max_tokens=4096,             # reserves OUTPUT room inside the window (see 1.3)
    messages=history,
)

u = resp.usage
print(u.input_tokens)                 # uncached input tokens
print(u.cache_read_input_tokens)      # served from cache — still counts to window
print(u.cache_creation_input_tokens)  # written to cache — still counts to window
print(u.output_tokens)                # the reply (+ thinking) — also in the window

# Total window used = input + cache_read + cache_creation + output

TRADE-OFFS A big window is capacity, not a free lunch

✅ Large (1M) window

  • Fits long documents, big histories, many tools
  • Fewer premature "too long" errors
  • Default & standard-priced on top models

⚠️ Filling it up

  • Context rot — recall/accuracy fall as tokens climb
  • Every re-sent token is re-billed each turn (1.4)
  • Latency and cost scale with what's in context

EXAM TRAPS

Trap: "The 1M window needs a beta header." → Not anymore. On Opus 4.8/4.7/4.6, Sonnet 5, Sonnet 4.6, and Fable 5, 1M is the default — no header, standard pricing.
Trap: "The context window is just the input." → It's the total input plus the generated output (including extended thinking). Reply tokens live in the same window.
Trap: "Tool definitions don't count." → They do. System prompt, all messages, tool results, images, documents, and tool definitions all consume the window.
Trap: "More context is always better." → No — context rot degrades recall as the window fills. Curate what goes in; a bigger window is headroom, not a dumping ground.

PRACTICE

Q1 · Which models have a 1M-token context window today, and what enables it?

Opus 4.8 / 4.7 / 4.6, Sonnet 5, Sonnet 4.6, and Fable 5 / Mythos 5. It's the default — no beta header, billed at standard pricing. Sonnet 4.5 and Haiku 4.5 are 200K.

Q2 · Name four things that consume the context window.

Any four of: the system prompt, every message in messages (including tool results, images, documents), the tool definitions, and the generated output (reply + extended thinking). All count.

Q3 · Why isn't a 1M window a reason to stop curating context?

Context rot: as token count grows, accuracy and recall degrade. And every token in the window is re-sent and re-billed each turn. Curating what's in context matters as much as the raw capacity.