Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions openhands-sdk/openhands/sdk/llm/utils/model_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = [
Expand Down
19 changes: 19 additions & 0 deletions tests/sdk/llm/test_chat_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/sdk/llm/test_model_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Loading