The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(models): /model --refresh shows a catalog that recovered mid-backoff
Teknium41c275928a94
diff --git a/hermes_cli/model_catalog.py b/hermes_cli/model_catalog.pyindex b57358b46b3..0824df716e0 100644--- a/hermes_cli/model_catalog.py+++ b/hermes_cli/model_catalog.py@@ -69,6 +69,13 @@ def _note_fetch_result(url: str, ok: bool) -> None:_fetch_retry_after[_backoff_key(url)] = time.monotonic() + FETCH_RETRY_DELAY_SECONDS+def clear_fetch_backoff() -> None:+ """Forget the active profile's fetch failures so an explicit refresh retries every URL."""+ from hermes_constants import hermes_home_key+ home = hermes_home_key()+ for key in [k for k in _fetch_retry_after if k[0] == home]:+ del _fetch_retry_after[key]+def _load_catalog_config() -> dict[str, Any]:"""Load the ``model_catalog`` config block with defaults filled in."""@@ -282,6 +289,7 @@ def refresh_catalogs() -> bool:Blocking; run it off the event loop."""if not _load_catalog_config()["enabled"]:return False+ clear_fetch_backoff() # provider overrides are re-asked too, not only the forced manifestcatalog = get_catalog(force_refresh=True)try:from hermes_cli.models import fetch_nous_recommended_models, fetch_openrouter_modelsdiff --git a/tests/hermes_cli/test_model_catalog.py b/tests/hermes_cli/test_model_catalog.pyindex b4573d759ac..99d9b7c4d3f 100644--- a/tests/hermes_cli/test_model_catalog.py+++ b/tests/hermes_cli/test_model_catalog.py@@ -155,6 +155,26 @@ class TestFetchFailure:with patch.object(model_catalog, "_fetch_manifest", return_value=_valid_manifest()):assert model_catalog.get_catalog() == _valid_manifest()+ def test_model_refresh_retries_a_backed_off_catalog(self, isolated_home):+ """``/model --refresh`` (``clear_provider_models_cache``) must show a catalog that came back+ inside the backoff window, override URL included."""+ from hermes_cli import model_catalog+ from hermes_cli.models import clear_provider_models_cache+ override = _valid_manifest()+ override["providers"]["openrouter"]["models"] = [{"id": "vendor/override-model", "description": ""}]+ cfg = {"enabled": True, "url": "http://master", "ttl_hours": 24.0,+ "providers": {"openrouter": {"url": "http://override"}}}+ with patch.object(model_catalog, "_load_catalog_config", return_value=cfg):+ with patch.object(model_catalog, "_fetch_manifest", return_value=None):+ assert model_catalog.get_curated_openrouter_models() is None++ def recovered(url, timeout):+ return override if "override" in url else _valid_manifest()++ with patch.object(model_catalog, "_fetch_manifest", side_effect=recovered):+ clear_provider_models_cache()+ assert model_catalog.get_curated_openrouter_models() == [("vendor/override-model", "")]+def test_override_failure_backs_off_per_profile(self, isolated_home, tmp_path):"""A multiplexed gateway serves many profiles: one profile's dead override must notsuppress another profile's request to the same URL."""