diff --git a/tests/hermes_cli/test_runtime_provider_resolution.py b/tests/hermes_cli/test_runtime_provider_resolution.py index bf2ea27cd..f251a3f24 100644 --- a/tests/hermes_cli/test_runtime_provider_resolution.py +++ b/tests/hermes_cli/test_runtime_provider_resolution.py @@ -1170,7 +1170,18 @@ def test_opencode_go_glm_defaults_to_chat_completions(monkeypatch): assert resolved["base_url"] == "https://opencode.ai/zen/go/v1" -def test_opencode_go_configured_api_mode_still_overrides_default(monkeypatch): +def test_opencode_go_model_derivation_beats_stale_persisted_api_mode(monkeypatch): + """opencode-zen/go re-derive api_mode from the effective model on every + resolve, ignoring any persisted ``api_mode`` in config. Refs #16878 / + PR #16888: the persisted mode from the previous default model must not + leak across /model switches (a stale ``anthropic_messages`` on a + chat_completions target would strip /v1 from base_url and 404). + + minimax-m2.5 is an Anthropic-routed model on opencode-go, so even when + the config claims ``api_mode: chat_completions`` the runtime must pick + ``anthropic_messages`` — the model dictates the mode, not the stale + persisted setting. + """ monkeypatch.setattr(rp, "resolve_provider", lambda *a, **k: "opencode-go") monkeypatch.setattr( rp, @@ -1187,7 +1198,7 @@ def test_opencode_go_configured_api_mode_still_overrides_default(monkeypatch): resolved = rp.resolve_runtime_provider(requested="opencode-go") assert resolved["provider"] == "opencode-go" - assert resolved["api_mode"] == "chat_completions" + assert resolved["api_mode"] == "anthropic_messages" def test_named_custom_provider_anthropic_api_mode(monkeypatch):