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.
This commit is contained in:
teknium1
2026-10-02 17:06:54 -07:00
committed by Teknium
parent 889a469c97
commit ffbecdca20
2 changed files with 13 additions and 7 deletions

View File

@@ -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

View File

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