Module context

Module context 

Source
Expand description

Context window management defaults Based on Anthropic context window documentation: https://docs.anthropic.com/en/docs/build-with-claude/context-windows

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)
CONTEXT_AWARE_MODELS
Models that support context awareness (budget tracking in prompts) Context awareness: model tracks remaining token budget throughout conversation Currently: Claude Sonnet 4.5, Claude Haiku 4.5
DEFAULT_THINKING_BUDGET
Default thinking budget for production use
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)
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
TOKEN_BUDGET_CRITICAL_THRESHOLD
Critical threshold - immediate action required At 90% usage: Force context handoff or summary
TOKEN_BUDGET_HIGH_THRESHOLD
Second warning threshold - active context management needed At 85% usage: Actively summarize and persist state
TOKEN_BUDGET_WARNING_THRESHOLD
First warning threshold - start preparing for context handoff At 70% usage: Consider updating key artifacts to persist context

Functions§

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