fix(ci): stabilize shared test state after 21012

This commit is contained in:
Stephen Schoettler 2026-05-14 14:28:14 -07:00
parent cd64bed55e
commit 5ce0067c08
7 changed files with 38 additions and 9 deletions

View file

@ -27,10 +27,12 @@ def _messages_with_handoff(summary_body: str):
return [
{"role": "system", "content": "system prompt"},
{"role": "user", "content": f"{SUMMARY_PREFIX}\n{summary_body}"},
{"role": "assistant", "content": "handoff acknowledged after resume"},
{"role": "user", "content": "new user turn after resume"},
{"role": "assistant", "content": "new assistant work after resume"},
{"role": "user", "content": "more new work after resume"},
{"role": "assistant", "content": "latest tail response"},
{"role": "user", "content": "final active request stays in protected tail"},
]

View file

@ -476,12 +476,14 @@ def _reset_module_state():
except Exception:
pass
# --- agent.auxiliary_client — runtime main provider/model override ---
# Set per-turn by AIAgent.run_conversation; tests that import it must
# see a clean state so config.yaml fallback works as expected.
# --- agent.auxiliary_client — runtime main provider/model override and
# payment-error health cache. Both are process-global in production;
# reset them per test so one worker's fallback/402 test does not make
# later auxiliary-client tests skip otherwise-available providers.
try:
from agent import auxiliary_client as _aux_mod
_aux_mod.clear_runtime_main()
_aux_mod._reset_aux_unhealthy_cache()
except Exception:
pass

View file

@ -305,6 +305,7 @@ def _setup_update_mocks(monkeypatch, tmp_path):
monkeypatch.setattr(hermes_config, "get_missing_config_fields", lambda: [])
monkeypatch.setattr(hermes_config, "check_config_version", lambda: (5, 5))
monkeypatch.setattr(hermes_config, "migrate_config", lambda **kw: {"env_added": [], "config_added": []})
monkeypatch.setattr(hermes_main, "_refresh_active_lazy_features", lambda: None)
def test_cmd_update_retries_optional_extras_individually_when_all_fails(monkeypatch, tmp_path, capsys):

View file

@ -46,14 +46,14 @@ def test_bundled_plugins_discovered():
assert (child / "plugin.yaml").exists(), f"{child.name} missing plugin.yaml"
def test_all_33_profiles_register():
"""After discovery, the registry must contain exactly 33 distinct profiles."""
def test_all_34_profiles_register():
"""After discovery, the registry must contain exactly 34 distinct profiles."""
_clear_provider_caches()
from providers import list_providers
profiles = list_providers()
names = sorted(p.name for p in profiles)
assert len(names) == 33, f"Expected 33 profiles, got {len(names)}: {names}"
assert len(names) == 34, f"Expected 34 profiles, got {len(names)}: {names}"
# Spot-check representative providers from different categories
for required in (

View file

@ -16,6 +16,16 @@ from run_agent import AIAgent
from agent.context_compressor import ContextCompressor
@pytest.fixture(autouse=True)
def _stable_aux_provider_config():
"""Keep feasibility tests independent from the developer's config.yaml."""
with patch(
"agent.auxiliary_client._resolve_task_provider_model",
return_value=("auto", None, None, None, None),
):
yield
def _make_agent(
*,
compression_enabled: bool = True,
@ -41,6 +51,7 @@ def _make_agent(
agent.tool_progress_callback = None
agent._compression_warning = None
agent._aux_compression_context_length_config = None
agent._custom_providers = []
agent.tools = []
compressor = MagicMock(spec=ContextCompressor)
@ -182,6 +193,7 @@ def test_feasibility_check_passes_config_context_length(mock_get_client, mock_ct
api_key="sk-custom",
config_context_length=1_000_000,
provider="openrouter",
custom_providers=[],
)
@ -205,6 +217,7 @@ def test_feasibility_check_ignores_invalid_context_length(mock_get_client, mock_
api_key="sk-test",
config_context_length=None,
provider="openrouter",
custom_providers=[],
)
@ -258,6 +271,7 @@ def test_init_feasibility_check_uses_aux_context_override_from_config():
api_key="sk-custom",
config_context_length=1_000_000,
provider="",
custom_providers=[],
)