Skip to content

Commit 225d7be

Browse files
ClintonEmokjacob3712
authored andcommitted
Fix #5211: Preserve dots in OpenCode Go model names
OpenCode Go model names with dots (minimax-m2.7, glm-4.5, kimi-k2.5) were being mangled to hyphens (minimax-m2-7), causing HTTP 401 errors. Two code paths were affected: 1. model_normalize.py: opencode-go was incorrectly in DOT_TO_HYPHEN_PROVIDERS 2. run_agent.py: _anthropic_preserve_dots() did not check for opencode-go Fix: - Remove opencode-go from _DOT_TO_HYPHEN_PROVIDERS (dots are correct for Go) - Add opencode-go to _anthropic_preserve_dots() provider check - Add opencode.ai/zen/go to base_url fallback check - Add regression tests in tests/test_model_normalize.py Co-authored-by: jacob3712 <[email protected]>
1 parent 582dbbb commit 225d7be

3 files changed

Lines changed: 123 additions & 5 deletions

File tree

‎hermes_cli/model_normalize.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
hyphens: ``claude-sonnet-4-6``.
99
- **Copilot** expects bare names *with* dots preserved:
1010
``claude-sonnet-4.6``.
11-
- **OpenCode** (Zen & Go) follows the same dot-to-hyphen convention as
11+
- **OpenCode Zen** follows the same dot-to-hyphen convention as
1212
Anthropic: ``claude-sonnet-4-6``.
13+
- **OpenCode Go** preserves dots in model names: ``minimax-m2.7``.
1314
- **DeepSeek** only accepts two model identifiers:
1415
``deepseek-chat`` and ``deepseek-reasoner``.
1516
- **Custom** and remaining providers pass the name through as-is.
@@ -67,7 +68,6 @@
6768
_DOT_TO_HYPHEN_PROVIDERS: frozenset[str] = frozenset({
6869
"anthropic",
6970
"opencode-zen",
70-
"opencode-go",
7171
})
7272

7373
# Providers that want bare names with dots preserved.

‎run_agent.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5224,11 +5224,13 @@ def _prepare_anthropic_messages_for_api(self, api_messages: list) -> list:
52245224
return transformed
52255225

52265226
def _anthropic_preserve_dots(self) -> bool:
5227-
"""True when using Alibaba/DashScope anthropic-compatible endpoint (model names keep dots, e.g. qwen3.5-plus)."""
5228-
if (getattr(self, "provider", "") or "").lower() == "alibaba":
5227+
"""True when using an anthropic-compatible endpoint that preserves dots in model names.
5228+
Alibaba/DashScope keeps dots (e.g. qwen3.5-plus).
5229+
OpenCode Go keeps dots (e.g. minimax-m2.7)."""
5230+
if (getattr(self, "provider", "") or "").lower() in {"alibaba", "opencode-go"}:
52295231
return True
52305232
base = (getattr(self, "base_url", "") or "").lower()
5231-
return "dashscope" in base or "aliyuncs" in base
5233+
return "dashscope" in base or "aliyuncs" in base or "opencode.ai/zen/go" in base
52325234

52335235
def _build_api_kwargs(self, api_messages: list) -> dict:
52345236
"""Build the keyword arguments dict for the active API mode."""

‎tests/test_model_normalize.py‎

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
"""Tests for hermes_cli.model_normalize — provider-aware model name normalization.
2+
3+
Covers issue #5211: opencode-go model names with dots (e.g. minimax-m2.7)
4+
must NOT be mangled to hyphens (minimax-m2-7).
5+
"""
6+
import pytest
7+
8+
from hermes_cli.model_normalize import (
9+
normalize_model_for_provider,
10+
_DOT_TO_HYPHEN_PROVIDERS,
11+
_AGGREGATOR_PROVIDERS,
12+
detect_vendor,
13+
)
14+
15+
16+
# ── Regression: issue #5211 ────────────────────────────────────────────
17+
18+
class TestIssue5211OpenCodeGoDotPreservation:
19+
"""OpenCode Go model names with dots must pass through unchanged."""
20+
21+
@pytest.mark.parametrize("model,expected", [
22+
("minimax-m2.7", "minimax-m2.7"),
23+
("minimax-m2.5", "minimax-m2.5"),
24+
("glm-4.5", "glm-4.5"),
25+
("kimi-k2.5", "kimi-k2.5"),
26+
("some-model-1.0.3", "some-model-1.0.3"),
27+
])
28+
def test_opencode_go_preserves_dots(self, model, expected):
29+
result = normalize_model_for_provider(model, "opencode-go")
30+
assert result == expected, f"Expected {expected!r}, got {result!r}"
31+
32+
def test_opencode_go_not_in_dot_to_hyphen_set(self):
33+
"""opencode-go must NOT be in the dot-to-hyphen provider set."""
34+
assert "opencode-go" not in _DOT_TO_HYPHEN_PROVIDERS
35+
36+
37+
# ── Anthropic dot-to-hyphen conversion (regression) ────────────────────
38+
39+
class TestAnthropicDotToHyphen:
40+
"""Anthropic API still needs dots→hyphens."""
41+
42+
@pytest.mark.parametrize("model,expected", [
43+
("claude-sonnet-4.6", "claude-sonnet-4-6"),
44+
("claude-opus-4.5", "claude-opus-4-5"),
45+
])
46+
def test_anthropic_converts_dots(self, model, expected):
47+
result = normalize_model_for_provider(model, "anthropic")
48+
assert result == expected
49+
50+
def test_anthropic_strips_vendor_prefix(self):
51+
result = normalize_model_for_provider("anthropic/claude-sonnet-4.6", "anthropic")
52+
assert result == "claude-sonnet-4-6"
53+
54+
55+
# ── OpenCode Zen regression ────────────────────────────────────────────
56+
57+
class TestOpenCodeZenDotToHyphen:
58+
"""OpenCode Zen follows Anthropic convention (dots→hyphens)."""
59+
60+
@pytest.mark.parametrize("model,expected", [
61+
("claude-sonnet-4.6", "claude-sonnet-4-6"),
62+
("glm-4.5", "glm-4-5"),
63+
])
64+
def test_zen_converts_dots(self, model, expected):
65+
result = normalize_model_for_provider(model, "opencode-zen")
66+
assert result == expected
67+
68+
def test_zen_strips_vendor_prefix(self):
69+
result = normalize_model_for_provider("opencode-zen/claude-sonnet-4.6", "opencode-zen")
70+
assert result == "claude-sonnet-4-6"
71+
72+
73+
# ── Copilot dot preservation (regression) ──────────────────────────────
74+
75+
class TestCopilotDotPreservation:
76+
"""Copilot preserves dots in model names."""
77+
78+
@pytest.mark.parametrize("model,expected", [
79+
("claude-sonnet-4.6", "claude-sonnet-4.6"),
80+
("gpt-5.4", "gpt-5.4"),
81+
])
82+
def test_copilot_preserves_dots(self, model, expected):
83+
result = normalize_model_for_provider(model, "copilot")
84+
assert result == expected
85+
86+
87+
# ── Aggregator providers (regression) ──────────────────────────────────
88+
89+
class TestAggregatorProviders:
90+
"""Aggregators need vendor/model slugs."""
91+
92+
def test_openrouter_prepends_vendor(self):
93+
result = normalize_model_for_provider("claude-sonnet-4.6", "openrouter")
94+
assert result == "anthropic/claude-sonnet-4.6"
95+
96+
def test_nous_prepends_vendor(self):
97+
result = normalize_model_for_provider("gpt-5.4", "nous")
98+
assert result == "openai/gpt-5.4"
99+
100+
def test_vendor_already_present(self):
101+
result = normalize_model_for_provider("anthropic/claude-sonnet-4.6", "openrouter")
102+
assert result == "anthropic/claude-sonnet-4.6"
103+
104+
105+
# ── detect_vendor ──────────────────────────────────────────────────────
106+
107+
class TestDetectVendor:
108+
@pytest.mark.parametrize("model,expected", [
109+
("claude-sonnet-4.6", "anthropic"),
110+
("gpt-5.4-mini", "openai"),
111+
("minimax-m2.7", "minimax"),
112+
("glm-4.5", "z-ai"),
113+
("kimi-k2.5", "moonshotai"),
114+
])
115+
def test_detects_known_vendors(self, model, expected):
116+
assert detect_vendor(model) == expected

0 commit comments

Comments
 (0)