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:
teknium1 2026-06-06 08:41:32 -07:00 committed by Teknium
parent fe0b3f2338
commit 03392b67d6
2 changed files with 19 additions and 10 deletions

View file

@ -24,7 +24,7 @@ class TestOpenCodeGoKimiReasoning:
reasoning_config={"enabled": True, "effort": "high"},
model="kimi-k2.6",
)
assert extra_body == {"thinking": {"type": "enabled"}}
assert extra_body == {}
assert top_level == {"reasoning_effort": "high"}
def test_disabled_emits_thinking_disabled_without_effort(self, opencode_go_profile):
@ -56,7 +56,7 @@ class TestOpenCodeGoKimiReasoning:
reasoning_config={"enabled": True, "effort": effort},
model="moonshotai/kimi-k2.6",
)
assert extra_body == {"thinking": {"type": "enabled"}}
assert extra_body == {}
assert top_level == {"reasoning_effort": "high"}
def test_low_and_medium_pass_through(self, opencode_go_profile):
@ -65,7 +65,7 @@ class TestOpenCodeGoKimiReasoning:
reasoning_config={"enabled": True, "effort": effort},
model="kimi-k2.5",
)
assert extra_body == {"thinking": {"type": "enabled"}}
assert extra_body == {}
assert top_level == {"reasoning_effort": effort}
def test_no_config_preserves_server_default(self, opencode_go_profile):
@ -85,7 +85,7 @@ class TestOpenCodeGoDeepSeekThinking:
reasoning_config={"enabled": True, "effort": "high"},
model="deepseek-v4-pro",
)
assert extra_body == {"thinking": {"type": "enabled"}}
assert extra_body == {}
assert top_level == {"reasoning_effort": "high"}
def test_disabled_emits_thinking_disabled_without_effort(self, opencode_go_profile):
@ -118,7 +118,7 @@ class TestOpenCodeGoDeepSeekThinking:
reasoning_config={"enabled": True, "effort": effort},
model="deepseek/deepseek-v4-pro",
)
assert extra_body == {"thinking": {"type": "enabled"}}
assert extra_body == {}
assert top_level == {"reasoning_effort": "max"}
@ -160,7 +160,7 @@ class TestOpenCodeGoFullKwargsIntegration:
reasoning_config={"enabled": True, "effort": "high"},
base_url="https://opencode.ai/zen/go/v1",
)
assert kwargs["extra_body"] == {"thinking": {"type": "enabled"}}
assert "extra_body" not in kwargs
assert kwargs["reasoning_effort"] == "high"
def test_deepseek_thinking_reaches_extra_body_and_top_level(
@ -176,5 +176,5 @@ class TestOpenCodeGoFullKwargsIntegration:
reasoning_config={"enabled": True, "effort": "high"},
base_url="https://opencode.ai/zen/go/v1",
)
assert kwargs["extra_body"] == {"thinking": {"type": "enabled"}}
assert "extra_body" not in kwargs
assert kwargs["reasoning_effort"] == "high"