The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(local-runtime): refresh bounces adopted servers too — downloads after a restart were invisible
emozilla9942b212b3fd
diff --git a/hermes_cli/local_runtime/bootstrap.py b/hermes_cli/local_runtime/bootstrap.pyindex 13f57569e6d..68b88cb60eb 100644--- a/hermes_cli/local_runtime/bootstrap.py+++ b/hermes_cli/local_runtime/bootstrap.py@@ -117,16 +117,30 @@ def refresh_local_runtime() -> bool:The router's model list is SPAWN-ONLY: a GGUF added after start isinvisible to GET /models and 400s on completion, so anything that- changes the staged set while the server runs must bounce it. Only- touches a server THIS process supervises; returns False when there is- nothing to refresh (next boot scans fresh anyway)."""+ changes the staged set while the server runs must bounce it. Covers+ both ownership shapes: a supervised server restarts in-process; an+ ADOPTED server (started by a previous backend session — the normal+ shape after any restart) is stopped via its state-file pid and+ replaced with a supervised boot. Without the adopted branch, every+ download/delete in a post-restart session silently no-ops the bounce+ and the router serves a stale catalog. Returns False when there is+ nothing to refresh (no server anywhere; next boot scans fresh).+ """global _SUPERVISOR- if _SUPERVISOR is None:- return Falsetry:from hermes_cli.config import load_config- shutdown_local_runtime()+ if _SUPERVISOR is None:+ from hermes_cli.local_runtime.endpoint import _state_endpoint++ state = _state_endpoint()+ if state is None:+ return False+ logger.info("bouncing adopted llama-server (pid=%s) to rescan models",+ state.get("pid"))+ _stop_state_server(state)+ else:+ shutdown_local_runtime()return ensure_local_runtime(load_config(), force=True) is not Noneexcept Exception as exc: # noqa: BLE001logger.warning("local runtime refresh failed: %s", exc)diff --git a/tests/hermes_cli/test_boot_preset_staleness.py b/tests/hermes_cli/test_boot_preset_staleness.pyindex 1ed7ee27756..fd7256c8bfc 100644--- a/tests/hermes_cli/test_boot_preset_staleness.py+++ b/tests/hermes_cli/test_boot_preset_staleness.py@@ -90,3 +90,37 @@ def test_boot_replaces_incumbent_with_stale_presets(hermes_home, monkeypatch):# Boot proceeded past adoption (our fake raised inside the try block,# which ensure_local_runtime swallows into a None return).assert result is None or result is sentinel+++def test_refresh_bounces_an_adopted_server(hermes_home, monkeypatch):+ """refresh_local_runtime with no in-process supervisor but a running+ state-file server (the post-restart shape) must stop that server and+ boot fresh — NOT silently no-op. Regression: the no-op meant every+ download/delete after a backend restart left the router serving a+ stale model catalog, and picking the new model failed with+ 'not found in this provider's model listing'."""+ import hermes_cli.local_runtime.bootstrap as boot++ stopped = {}+ monkeypatch.setattr(boot, "_SUPERVISOR", None)+ monkeypatch.setattr(+ "hermes_cli.local_runtime.endpoint._state_endpoint",+ lambda: {"base_url": "http://127.0.0.1:18434/v1", "pid": 4242})+ monkeypatch.setattr(boot, "_stop_state_server",+ lambda state: stopped.setdefault("pid", state["pid"]))+ booted = {}+ monkeypatch.setattr(boot, "ensure_local_runtime",+ lambda cfg, force=False: booted.setdefault("force", force) or object())++ assert boot.refresh_local_runtime() is True+ assert stopped.get("pid") == 4242, "adopted server was not stopped"+ assert booted.get("force") is True, "fresh boot did not follow the stop"+++def test_refresh_no_server_anywhere_is_a_noop(hermes_home, monkeypatch):+ import hermes_cli.local_runtime.bootstrap as boot++ monkeypatch.setattr(boot, "_SUPERVISOR", None)+ monkeypatch.setattr(+ "hermes_cli.local_runtime.endpoint._state_endpoint", lambda: None)+ assert boot.refresh_local_runtime() is False