mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-18 09:51:59 +00:00
fix(opencode-go): gate thinking when reasoning_effort set to avoid HTTP 400
Salvaged from #40429; re-verified on main, tightened, tested. Co-authored-by: jimjsong <jimjsong@users.noreply.github.com>
This commit is contained in:
parent
fe0b3f2338
commit
03392b67d6
2 changed files with 19 additions and 10 deletions
|
|
@ -64,9 +64,8 @@ class OpenCodeGoProfile(ProviderProfile):
|
|||
return extra_body, top_level
|
||||
|
||||
enabled = reasoning_config.get("enabled") is not False
|
||||
extra_body["thinking"] = {"type": "enabled" if enabled else "disabled"}
|
||||
|
||||
if not enabled:
|
||||
extra_body["thinking"] = {"type": "disabled"}
|
||||
return extra_body, top_level
|
||||
|
||||
effort = (reasoning_config.get("effort") or "").strip().lower()
|
||||
|
|
@ -74,6 +73,11 @@ class OpenCodeGoProfile(ProviderProfile):
|
|||
top_level["reasoning_effort"] = "high"
|
||||
elif effort in {"low", "medium", "high"}:
|
||||
top_level["reasoning_effort"] = effort
|
||||
|
||||
# Avoid "cannot specify both 'thinking' and 'reasoning_effort'" HTTP 400:
|
||||
# only send extra_body["thinking"] when no reasoning_effort is set.
|
||||
if "reasoning_effort" not in top_level:
|
||||
extra_body["thinking"] = {"type": "enabled"}
|
||||
return extra_body, top_level
|
||||
|
||||
if not _is_deepseek_thinking_model(model):
|
||||
|
|
@ -82,9 +86,9 @@ class OpenCodeGoProfile(ProviderProfile):
|
|||
enabled = True
|
||||
if isinstance(reasoning_config, dict) and reasoning_config.get("enabled") is False:
|
||||
enabled = False
|
||||
extra_body["thinking"] = {"type": "enabled" if enabled else "disabled"}
|
||||
|
||||
if not enabled:
|
||||
extra_body["thinking"] = {"type": "disabled"}
|
||||
return extra_body, top_level
|
||||
|
||||
if isinstance(reasoning_config, dict):
|
||||
|
|
@ -94,6 +98,11 @@ class OpenCodeGoProfile(ProviderProfile):
|
|||
elif effort in {"low", "medium", "high"}:
|
||||
top_level["reasoning_effort"] = effort
|
||||
|
||||
# Avoid "cannot specify both 'thinking' and 'reasoning_effort'" HTTP 400:
|
||||
# only send extra_body["thinking"] when no reasoning_effort is set.
|
||||
if "reasoning_effort" not in top_level:
|
||||
extra_body["thinking"] = {"type": "enabled"}
|
||||
|
||||
return extra_body, top_level
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue