-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Apps token limit #7474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apps token limit #7474
Changes from all commits
0815113
612710c
1068abd
2b4ca8b
2f1375b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -280,7 +280,6 @@ impl ModelConfig { | |
| return tokens; | ||
| } | ||
|
|
||
| // Priority 2: Global default | ||
| 4_096 | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -613,19 +613,19 @@ pub fn create_request( | |||||||
|
|
||||||||
| let is_thinking_enabled = std::env::var("CLAUDE_THINKING_ENABLED").is_ok(); | ||||||||
| if is_claude_sonnet && is_thinking_enabled { | ||||||||
| // Minimum budget_tokens is 1024 | ||||||||
| let budget_tokens = std::env::var("CLAUDE_THINKING_BUDGET") | ||||||||
| .unwrap_or_else(|_| "16000".to_string()) | ||||||||
| .parse() | ||||||||
| .unwrap_or(16000); | ||||||||
|
|
||||||||
| // For Claude models with thinking enabled, we need to add max_tokens + budget_tokens | ||||||||
| // Default to 8192 (Claude max output) + budget if not specified | ||||||||
| let max_completion_tokens = model_config.max_tokens.unwrap_or(8192); | ||||||||
| payload.as_object_mut().unwrap().insert( | ||||||||
| "max_tokens".to_string(), | ||||||||
| json!(max_completion_tokens + budget_tokens), | ||||||||
| ); | ||||||||
| // Anthropic requires budget_tokens >= 1024 | ||||||||
| const DEFAULT_THINKING_BUDGET: i32 = 16000; | ||||||||
| let budget_tokens: i32 = std::env::var("CLAUDE_THINKING_BUDGET") | ||||||||
| .ok() | ||||||||
| .and_then(|s| s.parse().ok()) | ||||||||
| .unwrap_or(DEFAULT_THINKING_BUDGET); | ||||||||
|
||||||||
| .unwrap_or(DEFAULT_THINKING_BUDGET); | |
| .unwrap_or(DEFAULT_THINKING_BUDGET) | |
| .max(1024); |
Copilot
AI
Feb 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model_config.max_output_tokens() + budget_tokens is an i32 addition that can overflow if CLAUDE_THINKING_BUDGET is set large, which can wrap to a negative max_tokens in release builds; use checked/saturating arithmetic (or compute in i64 and clamp) before serializing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i32 is 2 billion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,7 +149,7 @@ impl SageMakerTgiProvider { | |
| let request = json!({ | ||
| "inputs": prompt, | ||
| "parameters": { | ||
| "max_new_tokens": self.model.max_tokens.unwrap_or(150), | ||
| "max_new_tokens": self.model.max_output_tokens(), | ||
| "temperature": self.model.temperature.unwrap_or(0.7), | ||
|
Comment on lines
151
to
153
|
||
| "do_sample": true, | ||
| "return_full_text": false | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was separately thinking about making this bigger. Too small seems strictly worse as it can lead to truncation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had it higher for a bit, but presumably we almost always have a real value here so then erring on a lower side is probably better