Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(local-models): health check never loads a local model nothing selects
rubenluetke10-beepb58e934688ef
diff --git a/jarvis/local_models/health_monitor.py b/jarvis/local_models/health_monitor.pyindex 10c0bfd6b4..2b54df6d46 100644--- a/jarvis/local_models/health_monitor.py+++ b/jarvis/local_models/health_monitor.py@@ -55,6 +55,7 @@ HEALTH_FILE_NAME = "local_models_health.json"ProbeFn = Callable[[str], Awaitable[dict[str, Any]]]GenerateFn = Callable[[Any, str], Awaitable[Any]]+InUseFn = Callable[[Any], tuple[bool, str]]@dataclass(frozen=True, slots=True)@@ -224,6 +225,12 @@ async def _default_probe(root: str) -> dict[str, Any]:return await probe_host(root)+def _default_in_use(cfg: Any) -> tuple[bool, str]:+ from jarvis.local_models.autostart import in_use++ return in_use(cfg)++async def _default_generate(cfg: Any, model: str) -> Any:from jarvis.brain import provider_test@@ -239,8 +246,14 @@ async def check_once(probe: ProbeFn | None = None,generate: GenerateFn | None = None,persist: bool = True,+ in_use: InUseFn | None = None,) -> dict[str, Any] | None:- """One self-check; returns the record written, or ``None`` when skipped."""+ """One self-check; returns the record written, or ``None`` when skipped.++ The real generation only runs while local models are SELECTED (the active+ brain or voice, see ``autostart.in_use``); otherwise the check stops at+ the server probe.+ """root = root or _server_root(cfg)roles = _configured_roles(cfg)server = await (probe or _default_probe)(root)@@ -253,8 +266,19 @@ async def check_once(status, reason = "needs_setup", "Ollama runs, but no role is configured."else:model = roles.get("chat") or roles.get("deep") or roles.get("tools_screen") or ""+ used, why = (in_use or _default_in_use)(cfg)if not model:status, reason = "ok", ""+ elif not used:+ # A generation LOADS the model, and it stays resident behind its+ # keep-alive: a 14B chat pick put ~11 GB on the accelerator and in+ # RAM ten minutes after every boot, for half an hour, on a box whose+ # brain was a hosted provider — memory the WebView and the agents+ # needed (2026-09-28). The same trap as BUG-204, reached through+ # the badge instead of autostart. A server that answers is all the+ # badge can honestly claim for picks nothing uses.+ log.debug("health monitor: %s not generated — %s", model, why)+ status, reason = "ok", ""else:try:result = await asyncio.wait_for(diff --git a/tests/unit/local_models/test_health_monitor.py b/tests/unit/local_models/test_health_monitor.pyindex 567a149ed7..72830dc23a 100644--- a/tests/unit/local_models/test_health_monitor.py+++ b/tests/unit/local_models/test_health_monitor.py@@ -21,8 +21,11 @@ def _data_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:return tmp_path-def _cfg(chat: str = "", hours: float | None = None) -> JarvisConfig:+def _cfg(chat: str = "", hours: float | None = None, primary: str = "ollama") -> JarvisConfig:cfg = JarvisConfig()+ # Local models SELECTED unless a test says otherwise — the only state in+ # which the check may load a model (see test_unused_picks_are_never_loaded).+ cfg.brain.primary = primaryprovider = BrainProviderConfig(model=chat, base_url="http://fake:11434")if hours is not None:provider.health_check_hours = hours@@ -188,6 +191,36 @@ async def test_one_generation_decides_ok_or_error(tmp_path: Path) -> None:assert "did not answer" in record["reason"]+async def test_unused_picks_are_never_loaded(tmp_path: Path) -> None:+ """A hosted brain with local picks stored: probe the server, load nothing.++ One generation loads the pick and keeps it resident behind its keep-alive —+ a 14B model held ~11 GB for half an hour after every boot on a box that+ never asked a local model anything.+ """+ calls: list[str] = []++ async def generate(_cfg: Any, model: str) -> Any:+ calls.append(model)+ return _Result("ok")++ record = await hm.check_once(+ _cfg(chat="deepseek-r1:14b", primary="openrouter"),+ probe=_probe(True),+ generate=generate,+ )+ assert record == {"status": "ok", "reason": ""}+ assert calls == [], "a pick nothing selects must not be generated on"++ record = await hm.check_once(+ _cfg(chat="deepseek-r1:14b", primary="openrouter"),+ probe=_probe(True),+ generate=generate,+ in_use=lambda _cfg: (True, "the active realtime voice (local)"),+ )+ assert calls == ["deepseek-r1:14b"], "a local VOICE still counts as in use"++def test_read_record_defaults_without_a_file() -> None:assert hm.read_health_record() == {"status": "unknown",