fix - Set claude sonnet output limit (#11098)

This commit is contained in:
Ray Myers
2025-09-24 08:31:20 -05:00
committed by GitHub
parent 3977d4fdd7
commit 1e7024b60a
2 changed files with 18 additions and 11 deletions

View File

@@ -1053,17 +1053,22 @@ def test_claude_3_7_sonnet_max_output_tokens():
assert llm.config.max_input_tokens is None
def test_claude_sonnet_4_max_output_tokens():
@patch('openhands.llm.llm.litellm.get_model_info')
def test_claude_sonnet_4_max_output_tokens(mock_get_model_info):
"""Test that Claude Sonnet 4 models get the correct max_output_tokens and max_input_tokens values."""
mock_get_model_info.return_value = {
'max_input_tokens': 100000,
'max_output_tokens': 100000,
}
# Create LLM instance with a Claude Sonnet 4 model
config = LLMConfig(model='claude-sonnet-4-20250514', api_key='test_key')
llm = LLM(config, service_id='test-service')
llm.init_model_info()
# Verify max_output_tokens is set to the expected value
assert llm.config.max_output_tokens == 64000
# Verify max_input_tokens is set to the expected value
# For Claude models, we expect a specific value from litellm
assert llm.config.max_input_tokens == 200000
assert llm.config.max_output_tokens == 64000, 'output max should be decreased'
assert llm.config.max_input_tokens == 100000, (
'input max should be the litellm value'
)
def test_sambanova_deepseek_model_max_output_tokens():