From ffbecdca20a1933431c0848bbbf2228487f3437b Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Fri, 2 Oct 2026 17:06:54 -0700 Subject: [PATCH] fix(local-runtime): the CLI boots the managed server for an explicit backend _boot_in_flight gated the on-demand boot on installed_engine() with the default "auto", not the configured local_runtime.backend. With no GPU vendor detected, auto resolves to the CPU build only, so a user on `backend: vulkan` with only the Vulkan engine installed never got a boot from `hermes chat` ("The local model server isn't running"), while ensure_local_runtime itself would have booted that exact engine. Found during the live run for this PR. --- hermes_cli/local_runtime/endpoint.py | 6 +++--- tests/hermes_cli/test_local_runtime.py | 14 ++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/hermes_cli/local_runtime/endpoint.py b/hermes_cli/local_runtime/endpoint.py index de0d67d801..34c3e98a61 100644 --- a/hermes_cli/local_runtime/endpoint.py +++ b/hermes_cli/local_runtime/endpoint.py @@ -138,10 +138,10 @@ def _kick_managed_boot(config: dict | None) -> None: def _boot_in_flight(config: dict | None) -> bool: """True when the managed runtime is enabled and PM holds an installed engine.""" with suppress(Exception): - config = _load_config_if_none(config) - if not ((config or {}).get("local_runtime") or {}).get("enabled"): + section = (_load_config_if_none(config) or {}).get("local_runtime") or {} + if not section.get("enabled"): return False from hermes_cli.local_runtime.binaries import installed_engine - return installed_engine() is not None + return installed_engine(section.get("backend") or "auto") is not None return False diff --git a/tests/hermes_cli/test_local_runtime.py b/tests/hermes_cli/test_local_runtime.py index c814ea3524..18758b9950 100644 --- a/tests/hermes_cli/test_local_runtime.py +++ b/tests/hermes_cli/test_local_runtime.py @@ -484,18 +484,24 @@ def test_resolution_kicks_boot_when_no_thread_is_booting(tmp_path, monkeypatch): def test_boot_in_flight_real_gate(tmp_path, monkeypatch): """_boot_in_flight exercised FOR REAL (the previous regression test monkeypatched it — and the real one threw TypeError on every call, - silently disabling the boot wait). Enabled + installed PM engine - -> True; either missing -> False.""" + silently disabling the boot wait). Enabled + an installed PM engine for + the CONFIGURED backend -> True; either missing -> False.""" monkeypatch.setenv("HERMES_HOME", str(tmp_path / ".hermes")) from hermes_cli.local_runtime import endpoint as ep - monkeypatch.setattr("hermes_cli.local_runtime.binaries.installed_engine", lambda: None) + installed: set[str] = set() + monkeypatch.setattr("hermes_cli.local_runtime.binaries.installed_engine", + lambda backend="auto", **_: object() if backend in installed else None) enabled = {"local_runtime": {"enabled": True}} assert ep._boot_in_flight(enabled) is False - monkeypatch.setattr("hermes_cli.local_runtime.binaries.installed_engine", lambda: object()) + installed.add("auto") assert ep._boot_in_flight(enabled) is True # Disabled -> False even when installed. assert ep._boot_in_flight({"local_runtime": {"enabled": False}}) is False + # An explicit backend is the engine that boots: only the Vulkan build installed must count. + installed.clear() + installed.add("vulkan") + assert ep._boot_in_flight({"local_runtime": {"enabled": True, "backend": "vulkan"}}) is True def test_idle_sweep_unloads_idle_models(tmp_path, monkeypatch, stub_server):