vtcode_config/constants/context.rs
1/// Head ratio percentage for code files (legacy, kept for compatibility)
2pub const CODE_HEAD_RATIO_PERCENT: usize = 60;
3
4/// Head ratio percentage for log files (legacy, kept for compatibility)
5pub const LOG_HEAD_RATIO_PERCENT: usize = 20;
6
7// =========================================================================
8// Context Window Sizes
9// =========================================================================
10
11/// Standard context window size (200K tokens) - default for most models
12pub const STANDARD_CONTEXT_WINDOW: usize = 200_000;
13
14/// Extended context window size (1M tokens) - beta feature
15/// Available for Claude Sonnet 4, Sonnet 4.5 in usage tier 4
16/// Requires beta header: "context-1m-2025-08-07"
17pub const EXTENDED_CONTEXT_WINDOW: usize = 1_000_000;
18
19/// Claude.ai Enterprise context window (500K tokens)
20pub const ENTERPRISE_CONTEXT_WINDOW: usize = 500_000;
21
22// =========================================================================
23// Compaction Trigger Ratios
24// =========================================================================
25
26/// Fraction of the prompt budget that triggers auto-compaction when
27/// `auto_compaction_threshold_tokens` is unset. Applied in
28/// `resolve_compaction_threshold_with_reserve` (capacity − output reserve).
29/// 0.75 keeps long research turns from sitting in the expensive near-full
30/// zone (session data 2026-09-28: ~1M input tokens/turn) until 90% of the
31/// window is gone.
32pub const DEFAULT_COMPACTION_TRIGGER_RATIO: f64 = 0.75;
33
34// =========================================================================
35// Extended Thinking Token Management
36// =========================================================================
37
38/// Minimum budget tokens for extended thinking (Anthropic requirement)
39pub const MIN_THINKING_BUDGET: u32 = 1_024;
40
41/// Recommended budget tokens for complex reasoning tasks
42pub const RECOMMENDED_THINKING_BUDGET: u32 = 10_000;
43
44/// Default thinking budget for production use (64K output models: Opus 4.5, Sonnet 4.5, Haiku 4.5)
45/// Extended thinking is now auto-enabled by default as of January 2026
46pub const DEFAULT_THINKING_BUDGET: u32 = 31_999;
47
48/// Maximum thinking budget for 64K output models (Opus 4.5, Sonnet 4.5, Haiku 4.5)
49/// Use MAX_THINKING_TOKENS=63999 environment variable to enable this
50pub const MAX_THINKING_BUDGET_64K: u32 = 63_999;
51
52/// Maximum thinking budget for 32K output models (Opus 4)
53pub const MAX_THINKING_BUDGET_32K: u32 = 31_999;
54
55// =========================================================================
56// Beta Headers
57// =========================================================================
58
59/// Beta header for 1M token context window
60/// Include in requests to enable extended context for Sonnet 4/4.5
61pub const BETA_CONTEXT_1M: &str = "context-1m-2025-08-07";
62
63/// Models eligible for 1M context window (beta)
64/// Requires usage tier 4 or custom rate limits
65pub const EXTENDED_CONTEXT_ELIGIBLE_MODELS: &[&str] = &[
66 crate::constants::models::anthropic::CLAUDE_SONNET_5_5,
67 crate::constants::models::anthropic::CLAUDE_SONNET_5,
68 crate::constants::models::anthropic::CLAUDE_OPUS_5,
69 crate::constants::models::anthropic::CLAUDE_OPUS_5_5,
70];
71
72/// Check if a model is eligible for 1M context window
73pub fn supports_extended_context(model: &str) -> bool {
74 EXTENDED_CONTEXT_ELIGIBLE_MODELS.iter().any(|m| model.contains(m))
75}