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
feat(local-models): the switch applies what it persists — off means off
rubenluetke10-beep94ce6bfa974b
diff --git a/docs/BUGS.md b/docs/BUGS.mdindex 9064873de3..886ab39b46 100644--- a/docs/BUGS.md+++ b/docs/BUGS.md@@ -14425,6 +14425,30 @@ effect without a restart.it is a deliberate setting, and the idle release now returns what it borrows.An install that wants no local voice at all clears the fallback.+**The switch, same session.** In the maintainer's words: "you need a switch+between ON and OFF that simply works when you turn it off." The Server tab's+switch only decided what the NEXT launch would do, which is why turning it off+changed nothing on the card. It now applies what it persists:++- `PUT /runtime/autostart` — off stops the managed voice server, unloads every+ resident model and stops the local server; on readies it the way picking the+ local brain does. One click is the whole gesture in both directions.+- `supervisor.ensure_running` refuses an ambient spawn while the switch is off+ (`refused:local-models-off`). An ACTIVE choice still wins, so picking the+ local card is still "on" — but a realtime FALLBACK can no longer pull a+ 5.4 GB speech stack onto the card behind a hosted voice, which is exactly how+ this one got there.+- `should_autostart` names the one case where off cannot mean gone: the active+ brain IS the local server, so switching local models off would leave nothing+ to answer on. The sentence says so instead of leaving a resident model+ unexplained.+- The control reads "Local models on" in all three locales, and its description+ says what off does now.++**Measured on the maintainer's machine.** Graphics memory 15.7 GB → 3.2 GB of+16.3 after the switch-off path ran: the managed voice server, both resident+models and the local server all gone, with a hosted voice still answering.+**Related.** BUG-174 (the other local-models defect whose symptom was "voice onlocal models is unusably slow after a restart" — same stack, different half).@@ -14467,3 +14491,57 @@ runs on any machine, which is also how Apple Silicon and AMD get reported.**Not changed.** A pick already saved as an alias keeps working: the brain tierdeliberately accepts a model id that is not in the catalogue, so an existingconfiguration is shown rather than silently reset.++## BUG-206: an AMD or Intel graphics card was invisible to every local-model fit verdict (MEDIUM, FIXED 2026-08-28)++**Symptom.** On a machine with a discrete AMD card, every "will this model run+here?" verdict was judged against system RAM alone. A 20 GB model on a box with+a 16 GB Radeon and 32 GB of RAM read "Runs comfortably in 32 GB of memory" — it+does not; it spills to the processor and crawls. The Local models overview+showed "Graphics memory unknown" at the same time, so the panel was honest while+the verdict beside it was not.++**Cause.** `usable_accelerator_gb` knew exactly two sources: `nvidia-smi` (or+pynvml) and Apple-Silicon unified memory. Everything else returned+`(0.0, "none")`, and `fit_verdict` then skipped its accelerator branch entirely+and fell through to the RAM rule — the same rule that was already found+backwards for GPU boxes when the NVIDIA path was added. The 0 was correctly+DOCUMENTED as "unknown accelerator", but the fit verdict could not distinguish+"unknown" from "absent".++**Fix.** Two vendor-neutral sources between the NVIDIA leg and the Apple leg:++1. `_ollama_reported_gb()` — the `inference compute` record the server writes at+ startup, which names `library=CUDA` / `ROCm` / `Metal` and a `total=` for the+ device it will ACTUALLY use. One pattern therefore reads a card that would+ otherwise need three vendor SDKs, and it reports the budget the server+ decided on rather than one this process guessed for it. Best-effort by+ nature: the line is written once per start and rotates away with the log.+2. The OS's own inventory, which needs neither a running server nor a vendor+ tool — the display-class registry key `HardwareInformation.qwMemorySize` on+ Windows (the 64-bit field; the WMI `AdapterRAM` most code reaches for is a+ 32-bit one that reports 4 GB for every larger card), and+ `mem_info_vram_total` / `lmem_total_bytes` under `/sys/class/drm` on Linux,+ which `amdgpu` and `i915` both publish.++Cross-checked on the maintainer's box 2026-08-28: all three sources agreed on+the same card — nvidia-smi 15.92 GiB, the Ollama record 15.9 GiB, the registry+15.92 GiB.++**A Mac gains from source 1 too.** macOS hands the GPU only part of the unified+memory, so `apple-unified` (total RAM) overstates it. Where Ollama has already+named the real Metal budget, that figure now wins; the RAM figure stays as the+fallback for a Mac that has never started the server.++**Deliberately NOT widened: the realtime voice stack.** `derive_launch_command`+maps any non-`nvidia-smi` source to `mps`, so letting an AMD reading through+would have cleared the memory floor and then launched with a torch device the+box does not have. `preflight._DRIVEABLE_SOURCES` narrows the shared probe back+to the two sources that stack can drive, keeping its honest "no supported+accelerator" refusal exactly as `docs/os-parity.md` P-28 describes it.++**Guard.** `tests/unit/hardware/test_accelerator_probe.py` — the probe's first+test file. Every consumer used to monkeypatch it to a fixed pair, so the+function producing those pairs had no coverage: the Apple branch and the+"nothing readable" fallback had never been executed. All legs are driven through+fakes, so the suite proves them on a headless container too.diff --git a/jarvis/local_models/autostart.py b/jarvis/local_models/autostart.pyindex f5defef96f..b87cd4f7d0 100644--- a/jarvis/local_models/autostart.py+++ b/jarvis/local_models/autostart.py@@ -68,6 +68,7 @@ RunFn = Callable[[Any], Awaitable[dict[str, Any]]]StopFn = Callable[[], tuple[bool, str]]UnloadFn = Callable[[str], Awaitable[list[str]]]ReleaseFn = Callable[[Any], Awaitable[dict[str, Any]]]+VoiceStopFn = Callable[[], Awaitable[bool]]#: Live task references — a fire-and-forget task must be held somewhere or#: the loop may drop it mid-run.@@ -126,11 +127,20 @@ def in_use(cfg: Any) -> tuple[bool, str]:def should_autostart(cfg: Any) -> tuple[bool, str]:- """``(start, why)`` — the boot decision, in one sentence either way."""+ """``(start, why)`` — the boot decision, in one sentence either way.++ The off sentence names the one case where "off" cannot mean "gone": the+ active brain or voice is itself the local server, so switching local+ models off would leave Jarvis with nothing to answer on. The user reads+ that instead of watching a model stay resident with no explanation.+ """from jarvis.core.config import ollama_autostart # lazy (AP-26)if not ollama_autostart(cfg):- return False, "autostart is switched off in the Server tab"+ used, why = in_use(cfg)+ if used:+ return False, f"local models are switched off, but {why} still runs on them"+ return False, "local models are switched off"used, why = in_use(cfg)if not used:return False, why@@ -294,29 +304,57 @@ def kick(cfg: Any, *, run: RunFn | None = None) -> asyncio.Task[None] | None:return _remember(loop.create_task(_now(), name="local-models-kick"))+async def _stop_local_voice_server() -> bool:+ """Stop the managed local speech server, if this install is running one.++ It is a local model too — the biggest one on the card — and it holds the+ model server open as its brain, so releasing the accelerator without it+ frees nothing. Only ever the process this install owns+ (``owned_only=True``); a foreign one is left alone.+ """+ try:+ from jarvis.realtime.local_server import supervisor # lazy (AP-26)++ ok, detail = await asyncio.to_thread(supervisor.stop, owned_only=True)+ except Exception as exc: # noqa: BLE001 — no managed voice server is the normal case+ log.debug("local-models: managed voice server not stopped (%s)", exc, exc_info=True)+ return False+ if ok:+ log.info("local-models: managed voice server stopped — %s", detail)+ return bool(ok)++async def release_once(cfg: Any,*,unload: UnloadFn | None = None,stop: StopFn | None = None,+ voice_stop: VoiceStopFn | None = None,) -> dict[str, Any]:- """Hand the accelerator back: unload what is resident, stop our server.-- Returns ``{"stopped", "unloaded", "detail"}`` — ``unloaded`` the models- freed, ``stopped`` whether the server this install spawned was stopped,- ``detail`` one sentence. Refuses while :func:`in_use` still holds (a- local voice may keep answering on a hosted brain), and the runtime only- ever stops the pid Jarvis recorded, so a server the user started from- the tray or a terminal is left alone. Never raises.+ """Hand the accelerator back: stop the local voice stack and our server.++ Returns ``{"stopped", "unloaded", "voice_stopped", "detail"}`` — the+ models freed, whether the server this install spawned was stopped, and+ whether a managed voice server went with it. Refuses while+ :func:`in_use` still holds (a local voice may keep answering on a hosted+ brain), and the runtime only ever stops the pid Jarvis recorded, so a+ server the user started from the tray or a terminal is left alone.+ Never raises."""from jarvis.brain import ollama_runtime # lazy (AP-26)from jarvis.local_models.health_monitor import server_root # lazy (AP-26)- record: dict[str, Any] = {"stopped": False, "unloaded": [], "detail": ""}+ record: dict[str, Any] = {+ "stopped": False,+ "unloaded": [],+ "voice_stopped": False,+ "detail": "",+ }used, why = in_use(cfg)if used:record["detail"] = f"kept running — {why} still uses it"return record+ record["voice_stopped"] = await (voice_stop or _stop_local_voice_server)()root = server_root(cfg)if ollama_runtime.host_kind(root) == "remote":record["detail"] = f"The server at {root} is remote; this install does not stop it."@@ -349,8 +387,9 @@ def release(cfg: Any, *, run: ReleaseFn | None = None) -> asyncio.Task[None] | Ntry:record = await (run or release_once)(cfg)log.info(- "local-models: server released after the brain switch — stopped=%s unloaded=%r %s",+ "local-models: released — stopped=%s voice_stopped=%s unloaded=%r %s",record.get("stopped"),+ record.get("voice_stopped"),record.get("unloaded"),record.get("detail") or "",)diff --git a/jarvis/realtime/local_server/supervisor.py b/jarvis/realtime/local_server/supervisor.pyindex 9a0ffa70fc..70765c2e05 100644--- a/jarvis/realtime/local_server/supervisor.py+++ b/jarvis/realtime/local_server/supervisor.py@@ -1178,6 +1178,38 @@ def _uses_loopback_bind(command: str) -> bool:return host is not None and _is_loopback(host.strip().strip("[]"))+def _local_models_switched_off() -> str:+ """``"refused:local-models-off"`` when the switch is off and nothing chose us.++ The Local models switch means what it says: no local model server starts+ on its own while it is off (BUG-204). A fallback quietly spawning a+ multi-GB speech stack — and the model server behind it — while a hosted+ provider is the SELECTED voice is precisely what the user switched off.++ An active choice still wins: picking the local card IS turning it on, so+ only ambient starts are refused. An unreadable setting never refuses —+ the voice path must not go silent over a config hiccup.+ """+ try:+ from jarvis.core.config import load_config, ollama_autostart # lazy (AP-26)+ from jarvis.local_models.autostart import in_use # lazy (AP-26)++ cfg = load_config()+ if ollama_autostart(cfg):+ return ""+ used, _why = in_use(cfg)+ if used:+ return ""+ except Exception: # noqa: BLE001 — a settings hiccup must never mute the voice path+ log.debug("supervisor: local-models switch unreadable; allowing the spawn", exc_info=True)+ return ""+ log.info(+ "local-realtime supervisor: not spawning — local models are switched off and "+ "nothing active selects them"+ )+ return "refused:local-models-off"++def ensure_running(*,launch_command: str,@@ -1204,6 +1236,9 @@ def ensure_running(command = (launch_command or "").strip()if not command:return "refused:no-launch-command"+ switched_off = _local_models_switched_off()+ if switched_off:+ return switched_offhost, port = _host_port(base_url)if not _is_loopback(host):return "refused:not-local"diff --git a/jarvis/ui/web/frontend/src/i18n/locales/local_models/de.json b/jarvis/ui/web/frontend/src/i18n/locales/local_models/de.jsonindex f7efc3d4c5..41f1744ffa 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/local_models/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/local_models/de.json@@ -414,10 +414,10 @@"idle_save": "Speichern","idle_saving": "Speichern…","idle_hint": "0 lässt die Modelle geladen, solange Jarvis läuft. Gilt ab der nächsten Prüfung, kein Neustart nötig.",- "autostart_eyebrow": "Start",- "autostart_title": "Mit Jarvis starten",- "autostart_subtitle": "Beim Start von Jarvis kommt der lokale Server hoch und das Chat-Modell wird geladen, damit die erste Antwort schnell kommt — nur solange lokale Modelle in Gebrauch sind (das aktive Gehirn oder eine Rolle).",- "autostart_label": "Server mit Jarvis starten",+ "autostart_eyebrow": "Lokale Modelle",+ "autostart_title": "An oder aus",+ "autostart_subtitle": "Aus stoppt den lokalen Sprachserver, entlädt alle Modelle und gibt den Grafikspeicher sofort zurück — danach startet nichts Lokales mehr von selbst. An startet den Server mit Jarvis und lädt das Chat-Modell, damit die erste Antwort schnell kommt.",+ "autostart_label": "Lokale Modelle an","autostart_now": "Aktuell: {reason}.","autostart_saving": "Speichert…"},diff --git a/jarvis/ui/web/frontend/src/i18n/locales/local_models/en.json b/jarvis/ui/web/frontend/src/i18n/locales/local_models/en.jsonindex 0dcae51564..ceba9c4f2e 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/local_models/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/local_models/en.json@@ -414,10 +414,10 @@"idle_save": "Save","idle_saving": "Saving…","idle_hint": "0 keeps the models loaded while Jarvis runs. Applies on the next check, no restart needed.",- "autostart_eyebrow": "Start-up",- "autostart_title": "Start with Jarvis",- "autostart_subtitle": "When Jarvis starts, the local server comes up and the chat model is loaded, so the first answer is quick — only while local models are in use (the active brain, or a role).",- "autostart_label": "Start the server with Jarvis",+ "autostart_eyebrow": "Local models",+ "autostart_title": "On or off",+ "autostart_subtitle": "Off stops the local speech server, unloads every model and hands the graphics memory back right away — and nothing local starts on its own again. On brings the server up with Jarvis and loads the chat model, so the first answer is quick.",+ "autostart_label": "Local models on","autostart_now": "Right now: {reason}.","autostart_saving": "Saving…"},diff --git a/jarvis/ui/web/frontend/src/i18n/locales/local_models/es.json b/jarvis/ui/web/frontend/src/i18n/locales/local_models/es.jsonindex 8bdc67f4e3..ac0f705cc6 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/local_models/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/local_models/es.json@@ -414,10 +414,10 @@"idle_save": "Guardar","idle_saving": "Guardando…","idle_hint": "0 mantiene los modelos cargados mientras Jarvis funciona. Se aplica en la siguiente comprobación, sin reiniciar.",- "autostart_eyebrow": "Arranque",- "autostart_title": "Arrancar con Jarvis",- "autostart_subtitle": "Al iniciar Jarvis, el servidor local arranca y se carga el modelo de chat para que la primera respuesta sea rápida, solo mientras los modelos locales estén en uso (el cerebro activo o un rol).",- "autostart_label": "Arrancar el servidor con Jarvis",+ "autostart_eyebrow": "Modelos locales",+ "autostart_title": "Activar o desactivar",+ "autostart_subtitle": "Al desactivarlo se detiene el servidor de voz local, se descargan todos los modelos y la memoria gráfica se libera de inmediato; después nada local vuelve a arrancar por su cuenta. Al activarlo el servidor arranca con Jarvis y carga el modelo de chat para que la primera respuesta sea rápida.",+ "autostart_label": "Modelos locales activados","autostart_now": "Ahora mismo: {reason}.","autostart_saving": "Guardando…"},diff --git a/jarvis/ui/web/local_models_routes.py b/jarvis/ui/web/local_models_routes.pyindex 79253fc75d..5d11de1327 100644--- a/jarvis/ui/web/local_models_routes.py+++ b/jarvis/ui/web/local_models_routes.py@@ -955,7 +955,14 @@ async def get_autostart(provider_id: str, request: Request) -> AutostartResponseasync def put_autostart(provider_id: str, body: AutostartBody, request: Request) -> AutostartResponse:- """Switch "start the server with Jarvis" on or off (persisted)."""+ """Switch local models on or off — persisted AND applied to what runs now.++ Off means off (BUG-204): the switch stops the managed voice server,+ unloads every resident model and stops the server this install started,+ instead of only deciding what the NEXT launch does. On readies the+ server the same way picking the local brain does, so one click is the+ whole gesture in both directions.+ """_require_pull_capable(provider_id)from jarvis.local_models import autostart@@ -967,6 +974,10 @@ async def put_autostart(provider.autostart = bool(body.enabled)except Exception: # noqa: BLE001 — a frozen config object still has the TOML writelog.debug("local-models: in-memory autostart update skipped", exc_info=True)+ if body.enabled:+ autostart.kick(cfg)+ else:+ autostart.release(cfg)used, _why = autostart.in_use(cfg)_start, reason = autostart.should_autostart(cfg)return AutostartResponse(enabled=bool(body.enabled), in_use=used, reason=reason)diff --git a/tests/unit/local_models/test_autostart.py b/tests/unit/local_models/test_autostart.pyindex 88e1ce7939..4b144c2dca 100644--- a/tests/unit/local_models/test_autostart.py+++ b/tests/unit/local_models/test_autostart.py@@ -76,6 +76,18 @@ def test_the_switch_off_wins_over_use() -> None:assert start is True and "the active brain" in reason+def test_the_off_sentence_names_what_still_runs_on_the_server() -> None:+ """Off cannot mean gone while the active brain IS the local server.++ What would lie if it broke: the switch reading "off" beside a model that+ is still resident, with nothing on screen saying why (BUG-204).+ """+ _start, reason = autostart.should_autostart(_cfg(primary="ollama", flag=False))+ assert "switched off" in reason and "the active brain still runs on them" in reason+ _start, reason = autostart.should_autostart(_cfg(flag=False))+ assert reason == "local models are switched off"++def test_the_default_is_on_even_without_an_ollama_card() -> None:from jarvis.core.config import ollama_autostart@@ -226,17 +238,25 @@ async def test_the_brain_switch_readies_and_releases_the_local_server(@pytest.mark.asyncioasync def test_release_once_unloads_and_stops_when_nothing_uses_the_server() -> None:stopped: list[str] = []+ voice: list[str] = []async def _unload(root: str) -> list[str]:assert rootreturn ["ornith:9b-voice-32k", "qwen3.5:4b-voice-8k"]+ async def _voice_stop() -> bool:+ voice.append("go")+ return True+record = await autostart.release_once(_cfg(chat="qwen3.5:4b"),unload=_unload,stop=lambda: (stopped.append("go") or True, "Ollama stopped."),+ voice_stop=_voice_stop,)assert stopped == ["go"]+ # The speech stack is the biggest local model of the three; it goes too.+ assert voice == ["go"] and record["voice_stopped"] is Trueassert record["stopped"] is Trueassert record["unloaded"] == ["ornith:9b-voice-32k", "qwen3.5:4b-voice-8k"]@@ -248,10 +268,14 @@ async def test_release_once_keeps_a_server_something_still_uses() -> None:async def _unload(_root: str) -> list[str]:raise AssertionError("must not unload")+ async def _voice_stop() -> bool:+ raise AssertionError("must not stop the voice server")+record = await autostart.release_once(_cfg(realtime="local-realtime"),unload=_unload,stop=lambda: (_ for _ in ()).throw(AssertionError("must not stop")),+ voice_stop=_voice_stop,)assert record["stopped"] is False and "still uses it" in record["detail"]@@ -260,10 +284,15 @@ async def test_release_once_keeps_a_server_something_still_uses() -> None:async def test_release_once_never_stops_a_remote_server() -> None:cfg = _cfg()cfg.brain.providers["ollama"].base_url = "http://box.lan:11434"++ async def _voice_stop() -> bool:+ return False+record = await autostart.release_once(cfg,unload=lambda _root: (_ for _ in ()).throw(AssertionError("must not unload")),stop=lambda: (_ for _ in ()).throw(AssertionError("must not stop")),+ voice_stop=_voice_stop,)assert record["stopped"] is False and "remote" in record["detail"]diff --git a/tests/unit/realtime/local_server/test_supervisor.py b/tests/unit/realtime/local_server/test_supervisor.pyindex 2487329ca7..3185469d60 100644--- a/tests/unit/realtime/local_server/test_supervisor.py+++ b/tests/unit/realtime/local_server/test_supervisor.py@@ -26,6 +26,24 @@ from jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGSfrom jarvis.realtime.local_server import supervisor[email protected](autouse=True)+def _local_models_switch_on(monkeypatch: pytest.MonkeyPatch) -> None:+ """Pin the Local models switch ON for the cases that pin the spawn path.++ ``ensure_running`` refuses an ambient spawn while the switch is off+ (BUG-204). Without a pinned config every case in this file would read+ whatever jarvis.toml the machine happens to have and refuse for a reason+ it is not testing. The switch's own test re-pins the config itself.+ """+ from jarvis.core.config import BrainProviderConfig, JarvisConfig++ cfg = JarvisConfig()+ provider = BrainProviderConfig()+ provider.autostart = True+ cfg.brain.providers["ollama"] = provider+ monkeypatch.setattr("jarvis.core.config.load_config", lambda: cfg)++def _spawn_ready(monkeypatch, tmp_path: Path) -> list[dict[str, Any]]:"""Common arrangement: closed port, no pidfile, fake Popen, tmp data dir.@@ -83,6 +101,47 @@ def test_model_switch_never_interrupts_an_active_voice_call(monkeypatch, tmp_pat# ── Address parsing ──────────────────────────────────────────────────────+def test_the_local_models_switch_refuses_an_ambient_spawn(monkeypatch) -> None:+ """Off means no local model server starts on its own (BUG-204).++ What would lie if it broke: a realtime FALLBACK quietly spawning a+ multi-GB speech stack while a hosted provider is the selected voice and+ the user has switched local models off.+ """+ from jarvis.core.config import BrainProviderConfig, BrainTierConfig, JarvisConfig++ def _cfg(*, primary: str, realtime: str, autostart: bool) -> JarvisConfig:+ cfg = JarvisConfig()+ cfg.brain.primary = primary+ cfg.brain.realtime = BrainTierConfig(provider=realtime)+ provider = BrainProviderConfig()+ provider.autostart = autostart+ cfg.brain.providers["ollama"] = provider+ return cfg++ off = _cfg(primary="openrouter", realtime="gemini-live", autostart=False)+ monkeypatch.setattr("jarvis.core.config.load_config", lambda: off)+ assert supervisor._local_models_switched_off() == "refused:local-models-off"+ assert (+ supervisor.ensure_running(+ launch_command="speech-to-speech --mode realtime",+ base_url="ws://127.0.0.1:8765",+ reason="fallback",+ )+ == "refused:local-models-off"+ )++ # An ACTIVE choice still wins: picking the local card IS turning it on.+ chosen = _cfg(primary="openrouter", realtime="local-realtime", autostart=False)+ monkeypatch.setattr("jarvis.core.config.load_config", lambda: chosen)+ assert supervisor._local_models_switched_off() == ""++ # And the switch being ON never refuses.+ on = _cfg(primary="openrouter", realtime="gemini-live", autostart=True)+ monkeypatch.setattr("jarvis.core.config.load_config", lambda: on)+ assert supervisor._local_models_switched_off() == ""++def test_host_port_parses_the_configured_address() -> None:assert supervisor._host_port("http://localhost:8765") == ("localhost", 8765)assert supervisor._host_port("http://127.0.0.1:9000/v1") == ("127.0.0.1", 9000)