From 3127a41cb19f520dbeea93f21d29957fe0d11cde Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sat, 23 May 2026 01:42:15 -0700 Subject: [PATCH] test(acp): pin parse_model_input in slash-command tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The two ACP slash-command tests that exercise `provider:model` routing (`test_set_session_model_accepts_provider_prefixed_choice` and `test_model_switch_uses_requested_provider`) relied on the live `hermes_cli.models._KNOWN_PROVIDER_NAMES` / `_PROVIDER_ALIASES` module state to parse `anthropic:claude-sonnet-4-6` into `("anthropic", "claude-sonnet-4-6")`. If any earlier test in the same xdist worker registers a custom provider that shadows `anthropic` or otherwise mutates those globals, the parser falls into the `detect_provider_for_model` branch and resolves to `custom` instead. Observed once in CI on run 26326728502 / job 77505732299 as `AssertionError: assert 'custom' == 'anthropic'` — could not reproduce locally under per-file isolation, so the failing in-file order was specific to a particular xdist scheduling. Monkeypatching `parse_model_input` + `detect_provider_for_model` for both tests removes the global-catalog dependency, so the tests now only exercise what they were written to verify (the `requested_provider -> runtime -> AIAgent kwargs` plumbing). --- tests/acp/test_server.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/acp/test_server.py b/tests/acp/test_server.py index c1ff1bf4e63..6dce8d8702b 100644 --- a/tests/acp/test_server.py +++ b/tests/acp/test_server.py @@ -971,6 +971,18 @@ class TestSessionConfiguration: "hermes_cli.runtime_provider.resolve_runtime_provider", fake_resolve_runtime_provider, ) + # Pin the parser so this test doesn't depend on live + # ``_KNOWN_PROVIDER_NAMES`` / ``_PROVIDER_ALIASES`` module state + # (sibling of the same hardening on + # ``test_model_switch_uses_requested_provider``). + monkeypatch.setattr( + "hermes_cli.models.parse_model_input", + lambda raw, current: ("anthropic", "claude-sonnet-4-6"), + ) + monkeypatch.setattr( + "hermes_cli.models.detect_provider_for_model", + lambda model, current: None, + ) manager = SessionManager(db=SessionDB(tmp_path / "state.db")) with patch("run_agent.AIAgent", side_effect=fake_agent): @@ -1543,6 +1555,20 @@ class TestSlashCommands: "hermes_cli.runtime_provider.resolve_runtime_provider", fake_resolve_runtime_provider, ) + # Pin the model-string parser independently of the live + # ``_KNOWN_PROVIDER_NAMES`` / ``_PROVIDER_ALIASES`` module state. + # Otherwise any test in the same xdist worker that mutates those + # globals (e.g. registers a custom provider that shadows + # ``anthropic``) flakes this one — observed once in CI as + # ``'custom' == 'anthropic'``. + monkeypatch.setattr( + "hermes_cli.models.parse_model_input", + lambda raw, current: ("anthropic", "claude-sonnet-4-6"), + ) + monkeypatch.setattr( + "hermes_cli.models.detect_provider_for_model", + lambda model, current: None, + ) manager = SessionManager(db=SessionDB(tmp_path / "state.db")) with patch("run_agent.AIAgent", side_effect=fake_agent):