From 54e24f7758767f60000605afe1167efd926c49d7 Mon Sep 17 00:00:00 2001 From: Teknium Date: Tue, 28 Apr 2026 01:11:22 -0700 Subject: [PATCH] test(runtime_provider): lock in model-derivation precedence over stale api_mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #16888 swaps the opencode-zen/go resolver so that api_mode is always re-derived from the effective model before the persisted api_mode is consulted. That's the point of the fix — a stale anthropic_messages from a previous minimax default must not survive a /model switch to a chat_completions target (or vice versa) and strip /v1 from base_url. The prior test asserted the opposite precedence — that a persisted api_mode won over model-derived mode — and was added in #4508 to lock in escape-hatch behavior. Under the new precedence that escape hatch no longer exists for opencode (only for providers that genuinely support both modes at a single endpoint — and for opencode the model name is the unambiguous signal). Rename + invert the assertion to document the intentional behavior change. Refs #16878. --- .../test_runtime_provider_resolution.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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):