Add claude-sonnet-4-5 model support (#11179)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Xingyao Wang
2025-09-29 23:27:19 -04:00
committed by GitHub
parent c3da6c20bd
commit e19b3dd1f0
12 changed files with 32 additions and 8 deletions

View File

@@ -165,6 +165,7 @@ VERIFIED_OPENAI_MODELS = [
VERIFIED_ANTHROPIC_MODELS = [
'claude-sonnet-4-20250514',
'claude-sonnet-4-5-20250929',
'claude-opus-4-20250514',
'claude-opus-4-1-20250805',
'claude-3-7-sonnet-20250219',
@@ -186,6 +187,7 @@ VERIFIED_MISTRAL_MODELS = [
VERIFIED_OPENHANDS_MODELS = [
'claude-sonnet-4-20250514',
'claude-sonnet-4-5-20250929',
'gpt-5-2025-08-07',
'gpt-5-mini-2025-08-07',
'claude-opus-4-20250514',

View File

@@ -148,7 +148,10 @@ class LLM(RetryMixin, DebugMixin):
logger.debug(
f'Gemini model {self.config.model} with reasoning_effort {self.config.reasoning_effort} mapped to thinking {kwargs.get("thinking")}'
)
elif 'claude-sonnet-4-5' in self.config.model:
kwargs.pop(
'reasoning_effort', None
) # don't send reasoning_effort to Claude Sonnet 4.5
else:
kwargs['reasoning_effort'] = self.config.reasoning_effort
kwargs.pop(
@@ -507,6 +510,7 @@ class LLM(RetryMixin, DebugMixin):
'claude-3-7-sonnet',
'claude-3.7-sonnet',
'claude-sonnet-4',
'claude-sonnet-4-5-20250929',
]
if any(model in self.config.model for model in sonnet_models):
self.config.max_output_tokens = 64000 # litellm set max to 128k, but that requires a header to be set
@@ -817,6 +821,8 @@ class LLM(RetryMixin, DebugMixin):
message.force_string_serializer = True
if 'openrouter/anthropic/claude-sonnet-4' in self.config.model:
message.force_string_serializer = True
if 'openrouter/anthropic/claude-sonnet-4-5-20250929' in self.config.model:
message.force_string_serializer = True
# let pydantic handle the serialization
return [message.model_dump() for message in messages]

View File

@@ -103,6 +103,7 @@ REASONING_EFFORT_PATTERNS: list[str] = [
'gpt-5*',
# DeepSeek reasoning family
'deepseek-r1-0528*',
'claude-sonnet-4-5*',
]
PROMPT_CACHE_PATTERNS: list[str] = [

View File

@@ -56,6 +56,7 @@ def get_supported_llm_models(config: OpenHandsConfig) -> list[str]:
# Add OpenHands provider models
openhands_models = [
'openhands/claude-sonnet-4-20250514',
'openhands/claude-sonnet-4-5-20250929',
'openhands/gpt-5-2025-08-07',
'openhands/gpt-5-mini-2025-08-07',
'openhands/claude-opus-4-20250514',