test(runtime_provider): lock in model-derivation precedence over stale api_mode
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.
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user