Refine temperature/top_p handling for reasoning models#2277
Refine temperature/top_p handling for reasoning models#2277enyst merged 6 commits intoOpenHands:mainfrom
Conversation
Update handling of temperature and top_p for OpenAI models.
There was a problem hiding this comment.
Pull request overview
Updates chat-completion option normalization to avoid stripping sampling params (temperature, top_p) for non-OpenAI “reasoning effort” models (notably Gemini), while still handling OpenAI reasoning-model quirks.
Changes:
- Only remove
temperature/top_pfor OpenAI reasoning models (o1*,o3*) instead of all models that supportreasoning_effort. - Add model-name normalization logic in
select_chat_optionsto gate this behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
openhands-sdk/openhands/sdk/llm/options/chat_options.py:59
- The Gemini 2.5-pro substring check is case-sensitive and bypasses the
model_lowernormalization introduced above. For consistency with other model checks in this function (and withmodel_features.model_matches, which is case-insensitive), usemodel_lower(or another normalized form) so variants like provider-prefixed or differently-cased model IDs don’t skip this defaulting behavior.
# Gemini 2.5-pro default to low if not set
if "gemini-2.5-pro" in llm.model:
if llm.reasoning_effort in {None, "none"}:
out["reasoning_effort"] = "low"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
yes I understand @enyst but #1989 but still not fix my issue. If I have a reasoning model like gemini, then set the temperature to 0.0. then will be 1 (the default) |
enyst
left a comment
There was a problem hiding this comment.
Oh, I agree. I just don't fully understand, why keep the code for o1 and o3?
|
yes. maybe is not only o1 / o3 we need to make a list of models that the reasoning fail when temperature is set. |
|
Sounds good! |
|
[Automatic Post]: It has been a while since there was any activity on this PR. @mayeco, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. |
|
@enyst This approach is currently specific to the Gemini model. If we find that other models support reasoning_effort+temperature+top_p, we can add them to the exception list later. For now, we are 100% sure that Gemini supports it. https://docs.cloud.google.com/vertex-ai/generative-ai/docs/learn/prompts/adjust-parameter-values |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Update handling of temperature and top_p for OpenAI models.
This fix issue #2278
Checklist