Allow effort="max" for Claude Opus 4.6 (#21112)

This commit is contained in:
Kristoffer Arlind 2026-02-14 15:13:45 +08:00 • committed by GitHub
parent 495ce34165
commit edae273248
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 41 additions and 2 deletions

View file

@ -1238,9 +1238,13 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):
output_config = optional_params.get("output_config")
if output_config and isinstance(output_config, dict):
effort = output_config.get("effort")
if effort and effort not in ["high", "medium", "low"]:
if effort and effort not in ["high", "medium", "low", "max"]:
raise ValueError(
f"Invalid effort value: {effort}. Must be one of: 'high', 'medium', 'low'"
f"Invalid effort value: {effort}. Must be one of: 'high', 'medium', 'low', 'max'"
)
if effort == "max" and not self._is_claude_opus_4_6(model):
raise ValueError(
f"effort='max' is only supported by Claude Opus 4.6. Got model: {model}"
)
data["output_config"] = output_config

View file

@ -1638,6 +1638,41 @@ def test_effort_with_claude_opus_45():
assert result["model"] == "claude-opus-4-5-20251101"
def test_effort_validation_with_opus_46():
"""Test that all four effort levels are accepted for Claude Opus 4.6."""
config = AnthropicConfig()
messages = [{"role": "user", "content": "Test"}]
for effort in ["high", "medium", "low", "max"]:
optional_params = {"output_config": {"effort": effort}}
result = config.transform_request(
model="claude-opus-4-6-20260205",
messages=messages,
optional_params=optional_params,
litellm_params={},
headers={}
)
assert result["output_config"]["effort"] == effort
def test_max_effort_rejected_for_opus_45():
"""Test that effort='max' is rejected when using Claude Opus 4.5."""
config = AnthropicConfig()
messages = [{"role": "user", "content": "Test"}]
with pytest.raises(ValueError, match="effort='max' is only supported by Claude Opus 4.6"):
optional_params = {"output_config": {"effort": "max"}}
config.transform_request(
model="claude-opus-4-5-20251101",
messages=messages,
optional_params=optional_params,
litellm_params={},
headers={}
)
def test_effort_with_other_features():
"""Test effort works alongside other features (thinking, tools)."""
config = AnthropicConfig()