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):