Skip to content

The agent that grows with you

fix(tests): pin the provider:model prefix strip through AIAgent init, not just the helper

teknium175400793448e
diff --git a/tests/hermes_cli/test_model_normalize.py b/tests/hermes_cli/test_model_normalize.py
index 44d4b972f35..3e3263f4825 100644
--- a/tests/hermes_cli/test_model_normalize.py
+++ b/tests/hermes_cli/test_model_normalize.py
@@ -205,8 +205,23 @@ class TestColonProviderPrefixIsStrippedLikeSlash:
reached the Codex wire with the prefix attached and got HTTP 400. A matching ``provider:`` prefix
must normalize exactly like ``provider/``; a later colon (Ollama tags) is never a separator."""
+ def test_agent_init_strips_colon_prefix_before_the_wire(self, tmp_path, monkeypatch):
+ """Production path: ``AIAgent(model="openai-codex:gpt-5.6-sol", provider="openai-codex")`` —
+ the form that survives ``-m provider:model --provider X``, programmatic construction and
+ gateway config — must leave ``agent.model`` without the prefix (agent/agent_init.py)."""
+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))
+ (tmp_path / ".env").write_text("", encoding="utf-8")
+ (tmp_path / "config.yaml").write_text("{}\n", encoding="utf-8")
+ from run_agent import AIAgent
+
+ agent = AIAgent(
+ model="openai-codex:gpt-5.6-sol", provider="openai-codex", api_key="sk-dummy",
+ base_url="https://chatgpt.com/backend-api/codex", quiet_mode=True,
+ skip_context_files=True, skip_memory=True, platform="cli",
+ )
+ assert agent.model == "gpt-5.6-sol"
+
@pytest.mark.parametrize("model,provider,expected", [
- ("openai-codex:gpt-5.6-sol", "openai-codex", "gpt-5.6-sol"),
("openai:gpt-5.4", "openai-codex", "gpt-5.4"),
("zai:glm-5.1", "zai", "glm-5.1"),
("custom:qwen3:8b", "custom", "qwen3:8b"),