diff --git a/openhands-sdk/openhands/sdk/llm/utils/model_features.py b/openhands-sdk/openhands/sdk/llm/utils/model_features.py index 070c43ae6c1..32bf788e817 100644 --- a/openhands-sdk/openhands/sdk/llm/utils/model_features.py +++ b/openhands-sdk/openhands/sdk/llm/utils/model_features.py @@ -93,6 +93,11 @@ def _supports_reasoning_effort(model: str | None) -> bool: "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-haiku-4-5", + # Opus 4.8 is a reasoning model: Anthropic rejects requests with + # `temperature`/`top_p` ("`temperature` is deprecated for this model"), + # so it must go through the extended-thinking path which strips those + # params and enables the thinking budget header. + "claude-opus-4-8", ] PROMPT_CACHE_MODELS: list[str] = [ diff --git a/tests/sdk/llm/test_chat_options.py b/tests/sdk/llm/test_chat_options.py index 4f63e95270d..caf5fe5483c 100644 --- a/tests/sdk/llm/test_chat_options.py +++ b/tests/sdk/llm/test_chat_options.py @@ -147,6 +147,25 @@ def test_claude_sonnet_4_6_strips_temp_and_top_p(): assert "top_p" not in out +def test_claude_opus_4_8_strips_temp_and_top_p(): + """Test that claude-opus-4-8 strips temperature and top_p. + + Anthropic rejects requests to Claude Opus 4.8 with `temperature`/`top_p`: + ``"`temperature` is deprecated for this model."``. Routing the model + through the extended-thinking path strips both params (and enables the + thinking budget header) so requests succeed. + """ + llm = DummyLLM( + model="litellm_proxy/anthropic/claude-opus-4-8", + top_p=1.0, # SDK default + temperature=0.0, # Often overridden by benchmarks (e.g. SWE-bench) + ) + out = select_chat_options(llm, user_kwargs={}, has_tools=True) + + assert "temperature" not in out + assert "top_p" not in out + + def test_extended_thinking_budget_clamped_below_max_tokens(): """Test that thinking.budget_tokens is clamped to max_output_tokens - 1.""" # Case 1: extended_thinking_budget exceeds max_output_tokens diff --git a/tests/sdk/llm/test_model_features.py b/tests/sdk/llm/test_model_features.py index 5b6de7f6e86..23be24aa6ad 100644 --- a/tests/sdk/llm/test_model_features.py +++ b/tests/sdk/llm/test_model_features.py @@ -81,15 +81,19 @@ def test_reasoning_effort_support(model, expected_reasoning): ("claude-sonnet-4-5", True), ("claude-sonnet-4-6", True), ("claude-haiku-4-5", True), + ("claude-opus-4-8", True), # Provider prefixed variants ("anthropic/claude-sonnet-4-5", True), ("anthropic/claude-sonnet-4-6", True), ("anthropic/claude-haiku-4-5", True), + ("anthropic/claude-opus-4-8", True), + ("litellm_proxy/anthropic/claude-opus-4-8", True), # Models that don't support extended thinking ("claude-3-7-sonnet", False), ("claude-sonnet-4", False), ("claude-opus-4-5", False), ("claude-opus-4-6", False), + ("claude-opus-4-7", False), ("gpt-4o", False), ("o1", False), ("unknown-model", False),