Chapter 11: Context Window Management
Understanding Context Windows
Context windows determine how much information an agent can process at once. In 2026 the windows are large:
* Claude Fable 5.1 / Opus 5.5 / Sonnet 5.5: up to 1M tokens
* Claude Haiku 5.5: 1M tokens - the fast tier followed the flagship to 1M in October 2026 (the legacy Haiku 4.5 stays at 200K)
* Google Gemini 4 Argon: 1M tokens, shared by input, thinking, and output
* OpenAI GPT-6 Astra: about 1M tokens
* SpaceXAI Grok 4.7: 500K tokens
* Frontier open-weight models: commonly 128K-256K, served on your own infrastructure
A Token Is Not a Fixed Amount of Text
One thing about that list is easy to misread. A window is measured in tokens, and the tokenizer itself changed. Anthropic's current models use a newer tokenizer that produces roughly 30 percent more tokens for the same text, so 1M tokens is about 555,000 words on the current models against about 750,000 words on the generation before it. The window did not shrink, but a given file now costs more of it. Two consequences for planning: a cost-per-page figure carried over from an older model generation is wrong, and a context budget you tuned last year needs re-measuring rather than re-using. Measure your own corpus with the provider's token counter instead of converting from a word count.
More Context Is Not the Right Context
A million-token window does not mean you should pour the whole repository in. Relevance still degrades with noise, retrieval still beats brute force on cost and latency, and an agent given fifty files will reason worse than one given the five that matter. Curation wins.
Priority Hierarchy:
1. CRITICAL (Always include):
- Current task description and intent/constraints
- Relevant CLAUDE.md / AGENTS.md sections
- Files being directly modified
2. HIGH (Include when relevant):
- Related files and dependencies
- Test files for context
- API documentation
3. MEDIUM (Include selectively):
- Similar patterns from the codebase
- Recent changes (git diff)
- Error logs and stack traces
4. LOW (Omit unless needed):
- Generated files (dist/, build/)
- node_modules references
- Historical documentation
Context Optimization Strategies
Point, Don't Paste:
Instead of: "Analyze this 5000-line file"
Better: "Analyze the authentication functions
(lines 1200-1450) in user-service.js"
Summary Files:
// .claude/summaries/database-schema.md
Quick reference without full SQL dumps:
Users: id, email, password_hash, created_at
Posts: id, user_id (FK), title, content, published_at
Comments: id, post_id (FK), user_id (FK), content
Let Agents Retrieve: modern agents search the filesystem and call MCP tools on demand. Give them a good map (context files, summaries) and let them pull the exact lines they need, rather than front-loading everything into the window. Curated context plus on-demand retrieval beats a maximal dump every time.