fix: correct ultrathink token budget from 64000 to 63999
The Claude API requires max_tokens >= budget + 1, so setting the budget to 63999 allows max_tokens to be set to 64000 (the API limit). This fixes potential API rejections when using ultrathink mode. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,7 +25,7 @@ THINKING_BUDGET_MAP: dict[str, int | None] = {
|
|||||||
"low": 1024,
|
"low": 1024,
|
||||||
"medium": 4096, # Moderate analysis
|
"medium": 4096, # Moderate analysis
|
||||||
"high": 16384, # Deep thinking for QA review
|
"high": 16384, # Deep thinking for QA review
|
||||||
"ultrathink": 64000, # Maximum reasoning depth (within Claude API's 64000 token limit)
|
"ultrathink": 63999, # Maximum reasoning depth (API requires max_tokens >= budget + 1, so 63999 + 1 = 64000 limit)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Spec runner phase-specific thinking levels
|
# Spec runner phase-specific thinking levels
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export const THINKING_BUDGET_MAP: Record<string, number | null> = {
|
|||||||
low: 1024,
|
low: 1024,
|
||||||
medium: 4096,
|
medium: 4096,
|
||||||
high: 16384,
|
high: 16384,
|
||||||
ultrathink: 64000 // Maximum reasoning depth (Claude API hard limit)
|
ultrathink: 63999 // Maximum reasoning depth (API requires max_tokens >= budget + 1, so 63999 + 1 = 64000 limit)
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// ============================================
|
// ============================================
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ class TestThinkingLevelValidation:
|
|||||||
assert get_thinking_budget("none") is None
|
assert get_thinking_budget("none") is None
|
||||||
|
|
||||||
def test_ultrathink_max_budget(self):
|
def test_ultrathink_max_budget(self):
|
||||||
"""Test that 'ultrathink' returns maximum budget (Claude API's 64000 token limit)."""
|
"""Test that 'ultrathink' returns maximum budget (63999 so max_tokens = 63999 + 1 = 64000 limit)."""
|
||||||
assert get_thinking_budget("ultrathink") == 64000
|
assert get_thinking_budget("ultrathink") == 63999
|
||||||
|
|
||||||
def test_invalid_level_logs_warning(self, caplog):
|
def test_invalid_level_logs_warning(self, caplog):
|
||||||
"""Test that invalid thinking level logs a warning."""
|
"""Test that invalid thinking level logs a warning."""
|
||||||
@@ -89,4 +89,4 @@ class TestThinkingLevelValidation:
|
|||||||
assert get_thinking_budget("low") == 1024
|
assert get_thinking_budget("low") == 1024
|
||||||
assert get_thinking_budget("medium") == 4096
|
assert get_thinking_budget("medium") == 4096
|
||||||
assert get_thinking_budget("high") == 16384
|
assert get_thinking_budget("high") == 16384
|
||||||
assert get_thinking_budget("ultrathink") == 64000
|
assert get_thinking_budget("ultrathink") == 63999
|
||||||
|
|||||||
Reference in New Issue
Block a user