Skip to content

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

Merged
enyst merged 1 commit intoOpenHands:mainfrom
314clay:fix/claude-opus-4-6-temp-top-p
Feb 18, 2026
Merged

fix: add claude-opus-4-6 to temperature/top_p guard#12874
enyst merged 1 commit intoOpenHands:mainfrom
314clay:fix/claude-opus-4-6-temp-top-p

Conversation

@314clay
Copy link
Copy Markdown
Contributor

@314clay 314clay commented Feb 15, 2026

Summary

  • Adds claude-opus-4-6 to the existing model guard in openhands/llm/llm.py that drops top_p when both temperature and top_p are specified (Anthropic rejects both for this model family)
  • Adds matching unit test test_opus_46_keeps_temperature_drops_top_p

Fixes #12846

Test plan

  • New test test_opus_46_keeps_temperature_drops_top_p passes
  • All 5 existing temperature/top_p tests still pass (opus 4.1, opus 4.5, sonnet 4, opus 4 base)

🤖 Generated with Claude Code

Anthropic's claude-opus-4-6 model rejects requests with both temperature
and top_p set. Add it to the existing guard that drops top_p when both
are specified, matching the existing handling for opus-4-1, opus-4-5,
and sonnet-4.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@all-hands-bot all-hands-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean fix that correctly extends the existing temperature/top_p guard. Implementation follows the established pattern and includes proper test coverage.

Comment thread openhands/llm/llm.py
or ('claude-opus-4-5' in _model_lower)
or ('claude-opus-4-6' in _model_lower)
or ('claude-sonnet-4' in _model_lower)
) and ('temperature' in kwargs and 'top_p' in kwargs):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: Consider a pattern-based check like "claude-opus-4" in _model_lower to automatically cover future 4.x versions without code changes. However, the explicit approach is safer if future versions might have different behavior.

Copy link
Copy Markdown
Collaborator

@enyst enyst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@enyst enyst merged commit fede37b into OpenHands:main Feb 18, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

claude-opus-4-6 fails: temperature and top_p cannot both be specified

3 participants