Skip to main content

Module context

Module context 

Source
Expand description

Context window management defaults

Constants§

BETA_CONTEXT_1M
Beta header for 1M token context window Include in requests to enable extended context for Sonnet 4/4.5
CODE_HEAD_RATIO_PERCENT
Head ratio percentage for code files (legacy, kept for compatibility)
DEFAULT_COMPACTION_TRIGGER_RATIO
Default auto-compaction trigger ratio - at 90% prompt pressure, compaction fires.
DEFAULT_THINKING_BUDGET
Default thinking budget for production use (64K output models: Opus 4.5, Sonnet 4.5, Haiku 4.5) Extended thinking is now auto-enabled by default as of January 2026
ENTERPRISE_CONTEXT_WINDOW
Claude.ai Enterprise context window (500K tokens)
EXTENDED_CONTEXT_ELIGIBLE_MODELS
Models eligible for 1M context window (beta) Requires usage tier 4 or custom rate limits
EXTENDED_CONTEXT_WINDOW
Extended context window size (1M tokens) - beta feature Available for Claude Sonnet 4, Sonnet 4.5 in usage tier 4 Requires beta header: “context-1m-2025-08-07”
LOG_HEAD_RATIO_PERCENT
Head ratio percentage for log files (legacy, kept for compatibility)
MAX_THINKING_BUDGET_32K
Maximum thinking budget for 32K output models (Opus 4)
MAX_THINKING_BUDGET_64K
Maximum thinking budget for 64K output models (Opus 4.5, Sonnet 4.5, Haiku 4.5) Use MAX_THINKING_TOKENS=63999 environment variable to enable this
MIN_THINKING_BUDGET
Minimum budget tokens for extended thinking (Anthropic requirement)
RECOMMENDED_THINKING_BUDGET
Recommended budget tokens for complex reasoning tasks
STANDARD_CONTEXT_WINDOW
Standard context window size (200K tokens) - default for most models

Functions§

supports_extended_context
Check if a model is eligible for 1M context window