From 846b269b4ad8b623fa43dfaef4277728dfdbe36e Mon Sep 17 00:00:00 2001 From: Mario Young Date: Tue, 3 Mar 2026 08:33:02 -0500 Subject: [PATCH 1/3] Refine temperature/top_p handling for reasoning models Update handling of temperature and top_p for OpenAI models. --- openhands-sdk/openhands/sdk/llm/options/chat_options.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/openhands-sdk/openhands/sdk/llm/options/chat_options.py b/openhands-sdk/openhands/sdk/llm/options/chat_options.py index 7f29acd8db..46a8494907 100644 --- a/openhands-sdk/openhands/sdk/llm/options/chat_options.py +++ b/openhands-sdk/openhands/sdk/llm/options/chat_options.py @@ -39,9 +39,12 @@ def select_chat_options( if llm.reasoning_effort is not None: out["reasoning_effort"] = llm.reasoning_effort - # All reasoning models ignore temp/top_p - out.pop("temperature", None) - out.pop("top_p", None) + # OpenAI reasoning models (o1, o3) ignore temp/top_p + # Gemini models DO respect temperature, so we only pop for OpenAI + model_lower = llm.model.lower() + if "o1-" in model_lower or "o3-" in model_lower or model_lower.startswith("o1") or model_lower.startswith("o3"): + out.pop("temperature", None) + out.pop("top_p", None) # Gemini 2.5-pro default to low if not set if "gemini-2.5-pro" in llm.model: From 9aab1fc288c270bae61b390f7e0ccc4690483740 Mon Sep 17 00:00:00 2001 From: Mario Young Date: Tue, 3 Mar 2026 08:46:59 -0500 Subject: [PATCH 2/3] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- openhands-sdk/openhands/sdk/llm/options/chat_options.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openhands-sdk/openhands/sdk/llm/options/chat_options.py b/openhands-sdk/openhands/sdk/llm/options/chat_options.py index 46a8494907..d16547938a 100644 --- a/openhands-sdk/openhands/sdk/llm/options/chat_options.py +++ b/openhands-sdk/openhands/sdk/llm/options/chat_options.py @@ -42,7 +42,14 @@ def select_chat_options( # OpenAI reasoning models (o1, o3) ignore temp/top_p # Gemini models DO respect temperature, so we only pop for OpenAI model_lower = llm.model.lower() - if "o1-" in model_lower or "o3-" in model_lower or model_lower.startswith("o1") or model_lower.startswith("o3"): + # Normalize to basename so provider-prefixed IDs like "openai/o1" are handled + model_name = model_lower.split("/")[-1] + if ( + "o1-" in model_name + or "o3-" in model_name + or model_name.startswith("o1") + or model_name.startswith("o3") + ): out.pop("temperature", None) out.pop("top_p", None) From de10a5afb30f1590303c5561d71f357714c02684 Mon Sep 17 00:00:00 2001 From: Mario Young Date: Tue, 3 Mar 2026 08:52:51 -0500 Subject: [PATCH 3/3] Update openhands-sdk/openhands/sdk/llm/options/chat_options.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- openhands-sdk/openhands/sdk/llm/options/chat_options.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/openhands-sdk/openhands/sdk/llm/options/chat_options.py b/openhands-sdk/openhands/sdk/llm/options/chat_options.py index d16547938a..bb3c8fef5f 100644 --- a/openhands-sdk/openhands/sdk/llm/options/chat_options.py +++ b/openhands-sdk/openhands/sdk/llm/options/chat_options.py @@ -44,12 +44,7 @@ def select_chat_options( model_lower = llm.model.lower() # Normalize to basename so provider-prefixed IDs like "openai/o1" are handled model_name = model_lower.split("/")[-1] - if ( - "o1-" in model_name - or "o3-" in model_name - or model_name.startswith("o1") - or model_name.startswith("o3") - ): + if model_name.startswith(("o1", "o3")): out.pop("temperature", None) out.pop("top_p", None)