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/// Default auto-compaction trigger ratio - at 90% prompt pressure, compaction fires.
27pub const DEFAULT_COMPACTION_TRIGGER_RATIO: f64 = 0.90;
28
29// =========================================================================
30// Extended Thinking Token Management
31// =========================================================================
32
33/// Minimum budget tokens for extended thinking (Anthropic requirement)
34pub const MIN_THINKING_BUDGET: u32 = 1_024;
35
36/// Recommended budget tokens for complex reasoning tasks
37pub const RECOMMENDED_THINKING_BUDGET: u32 = 10_000;
38
39/// Default thinking budget for production use (64K output models: Opus 4.5, Sonnet 4.5, Haiku 4.5)
40/// Extended thinking is now auto-enabled by default as of January 2026
41pub const DEFAULT_THINKING_BUDGET: u32 = 31_999;
42
43/// Maximum thinking budget for 64K output models (Opus 4.5, Sonnet 4.5, Haiku 4.5)
44/// Use MAX_THINKING_TOKENS=63999 environment variable to enable this
45pub const MAX_THINKING_BUDGET_64K: u32 = 63_999;
46
47/// Maximum thinking budget for 32K output models (Opus 4)
48pub const MAX_THINKING_BUDGET_32K: u32 = 31_999;
49
50// =========================================================================
51// Beta Headers
52// =========================================================================
53
54/// Beta header for 1M token context window
55/// Include in requests to enable extended context for Sonnet 4/4.5
56pub const BETA_CONTEXT_1M: &str = "context-1m-2025-08-07";
57
58/// Models eligible for 1M context window (beta)
59/// Requires usage tier 4 or custom rate limits
60pub const EXTENDED_CONTEXT_ELIGIBLE_MODELS: &[&str] = &[
61 crate::constants::models::anthropic::CLAUDE_SONNET_4_6,
62 crate::constants::models::anthropic::CLAUDE_OPUS_4_6,
63];
64
65/// Check if a model is eligible for 1M context window
66pub fn supports_extended_context(model: &str) -> bool {
67 EXTENDED_CONTEXT_ELIGIBLE_MODELS
68 .iter()
69 .any(|m| model.contains(m))
70}