fix(model): normalize native provider-prefixed model ids

This commit is contained in:
Kenny Xie 2026-04-08 13:24:05 -07:00 committed by Teknium
parent 1662b7f82a
commit fd5cc6e1b4
6 changed files with 143 additions and 7 deletions

View file

@ -150,6 +150,12 @@ class TestNormalizeModelForProvider:
assert changed is False
assert cli.model == "gpt-5.4"
def test_native_provider_prefix_is_stripped_before_agent_startup(self):
cli = _make_cli(model="zai/glm-5.1")
changed = cli._normalize_model_for_provider("zai")
assert changed is True
assert cli.model == "glm-5.1"
def test_bare_codex_model_passes_through(self):
cli = _make_cli(model="gpt-5.3-codex")
changed = cli._normalize_model_for_provider("openai-codex")

View file

@ -102,6 +102,21 @@ class TestAggregatorProviders:
assert result == "anthropic/claude-sonnet-4.6"
class TestIssue6211NativeProviderPrefixNormalization:
@pytest.mark.parametrize("model,target_provider,expected", [
("zai/glm-5.1", "zai", "glm-5.1"),
("google/gemini-2.5-pro", "gemini", "gemini-2.5-pro"),
("moonshot/kimi-k2.5", "kimi-coding", "kimi-k2.5"),
("anthropic/claude-sonnet-4.6", "openrouter", "anthropic/claude-sonnet-4.6"),
("Qwen/Qwen3.5-397B-A17B", "huggingface", "Qwen/Qwen3.5-397B-A17B"),
("modal/zai-org/GLM-5-FP8", "custom", "modal/zai-org/GLM-5-FP8"),
])
def test_native_provider_prefixes_are_only_stripped_on_matching_provider(
self, model, target_provider, expected
):
assert normalize_model_for_provider(model, target_provider) == expected
# ── detect_vendor ──────────────────────────────────────────────────────
class TestDetectVendor: