fix: add claude-opus-4-6 to temperature/top_p guard (#12874)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Clay Arnold
2026-02-19 12:33:17 +13:00
committed by GitHub
parent 3bcd6f18df
commit fede37b496
2 changed files with 22 additions and 2 deletions

View File

@@ -1274,6 +1274,25 @@ def test_opus_45_keeps_temperature_drops_top_p(mock_completion):
assert 'top_p' not in call_kwargs
@patch('openhands.llm.llm.litellm_completion')
def test_opus_46_keeps_temperature_drops_top_p(mock_completion):
mock_completion.return_value = {
'choices': [{'message': {'content': 'ok'}}],
}
config = LLMConfig(
model='anthropic/claude-opus-4-6',
api_key='k',
temperature=0.7,
top_p=0.9,
)
llm = LLM(config, service_id='svc')
llm.completion(messages=[{'role': 'user', 'content': 'hi'}])
call_kwargs = mock_completion.call_args[1]
assert call_kwargs.get('temperature') == 0.7
# Anthropic rejects both temperature and top_p together on Opus 4.6; we keep temperature and drop top_p
assert 'top_p' not in call_kwargs
@patch('openhands.llm.llm.litellm_completion')
def test_sonnet_4_keeps_temperature_drops_top_p(mock_completion):
mock_completion.return_value = {