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 voice context is yours to set, and idle local models let go of the GPU
rubenluetke10-beepdc581bd0741c
diff --git a/jarvis/brain/ollama_roles.py b/jarvis/brain/ollama_roles.pyindex b290c33549..a1f5754abd 100644--- a/jarvis/brain/ollama_roles.py+++ b/jarvis/brain/ollama_roles.py@@ -151,6 +151,10 @@ class RoleState:recommended: str#: One sentence when the slot is not Ollama-backed right now.note: str = ""+ #: The voice brain's effective ``num_ctx`` on this machine (voice role only).+ context_tokens: int | None = None+ #: ``"automatic"`` (sized from memory) | ``"manual"`` (set in Tune) | ``""``.+ context_source: str = ""# ── Reading ──────────────────────────────────────────────────────────────@@ -307,6 +311,10 @@ async def list_roles(for spec in ROLES:current, note = current_pick(cfg, spec.id)qualifying = qualifying_models(spec, models)+ context_tokens: int | None = None+ context_source = ""+ if spec.id == "voice" and current and error is None:+ context_tokens, context_source = await voice_context(cfg, current)states.append(RoleState(spec=spec,@@ -315,11 +323,40 @@ async def list_roles(qualifying=qualifying,recommended=_recommended_for(spec, shortlist),note=note,+ context_tokens=context_tokens,+ context_source=context_source,))return states, error+async def voice_context(cfg: Any, model: str) -> tuple[int | None, str]:+ """``(num_ctx, source)`` the managed voice brain would run ``model`` with.++ Off the event loop: the sizing reads the machine's memory and asks Ollama+ for the model's facts. Any failure is ``(None, "")`` — the row then simply+ shows no context line rather than a guess.+ """+ import asyncio++ from jarvis.realtime.local_server import supervisor # lazy: off the read path++ command = _str(getattr(_voice_provider(cfg), "launch_command", ""))+ _model, base = supervisor._brain_endpoint(command)+ root = base[: -len("/v1")] if base.endswith("/v1") else base+ if not root.startswith(("http://", "https://")):+ return None, ""+ override = supervisor._voice_context_override(model)+ try:+ tokens, _why = await asyncio.to_thread(+ supervisor.voice_brain_context_tokens, root, model, timeout=2.0, override=override+ )+ except Exception: # noqa: BLE001 — a sizing failure must not break the roles list+ log.debug("ollama-roles: voice context sizing failed for %s", model, exc_info=True)+ return None, ""+ return tokens, "manual" if override else "automatic"++# ── Writing ──────────────────────────────────────────────────────────────diff --git a/jarvis/core/config.py b/jarvis/core/config.pyindex ec8d93f0d0..65aae0cb0f 100644--- a/jarvis/core/config.py+++ b/jarvis/core/config.py@@ -2887,6 +2887,13 @@ class VoiceConfig(BaseModel):# (``tool_declaration_budget_tokens`` capability, AP-21); the smaller of# the two applies. 0 disables the bound.realtime_tool_declaration_budget_tokens: int = 0+ # Minutes without a voice call after which the LOCAL voice stack lets go+ # of the accelerator: the managed voice server (its STT/TTS models) is+ # stopped and the Ollama voice brain's keep-alive is allowed to lapse.+ # The next call pays the cold start again. 0 = keep everything loaded+ # while Jarvis runs (the pre-2026-08-24 behaviour). Read by+ # ``jarvis.realtime.local_server.supervisor.idle_release_s``.+ local_idle_release_minutes: int = Field(default=30, ge=0, le=1440)# ADR-0034 (2026-08-18). When the user opens a NEW turn while an earlier# order's provider function call (jarvis_action) is still unanswered on# the wire, the session answers that call at once with a closed "stilldiff --git a/jarvis/core/config_writer.py b/jarvis/core/config_writer.pyindex b7230886fc..bd17ba7e53 100644--- a/jarvis/core/config_writer.py+++ b/jarvis/core/config_writer.py@@ -1425,6 +1425,17 @@ def set_session_idle_timeout_s(_patch_table(path, "trigger", "session_idle_timeout_s", value)+def set_local_idle_release_minutes(minutes: int, *, path: Path = DEFAULT_CONFIG_FILE) -> None:+ """Persist ``[voice] local_idle_release_minutes`` — how long the local voice+ stack may sit idle before it releases the accelerator (0 = never).++ Negative input is normalised to 0. Read by the local-realtime supervisor on+ its next monitor tick; no restart needed. TOML-only, like+ :func:`set_session_idle_timeout_s`.+ """+ _patch_table(path, "voice", "local_idle_release_minutes", max(0, int(minutes)))++def set_bar_persistent(enabled: bool, *, path: Path = DEFAULT_CONFIG_FILE) -> None:"""Persist ``[ui] bar_persistent`` (the 'show bar at all times' toggle).diff --git a/jarvis/realtime/local_server/supervisor.py b/jarvis/realtime/local_server/supervisor.pyindex 5013b711aa..d147102cf0 100644--- a/jarvis/realtime/local_server/supervisor.py+++ b/jarvis/realtime/local_server/supervisor.py@@ -103,6 +103,39 @@ BRAIN_KEEP_ALIVE = "2h"#: costs one empty HTTP request from a thread that is already polling.BRAIN_REWARM_INTERVAL_S = 45 * 60.0+#: Fallback for ``[voice] local_idle_release_minutes`` when the config cannot+#: be read (30 min). 0 = never release.+DEFAULT_IDLE_RELEASE_S = 30 * 60.0+++def idle_release_s() -> float:+ """Seconds of voice idleness after which the local stack frees the accelerator.++ Maintainer mandate 2026-08-24: graphics memory belongs to the local models+ only while they are actually in use. ``0`` keeps everything resident.+ Read fresh on every monitor tick so a settings change applies without a+ restart; an unreadable config keeps the default.+ """+ try:+ from jarvis.core.config import load_config++ minutes = getattr(getattr(load_config(), "voice", None), "local_idle_release_minutes", None)+ if minutes is None:+ return DEFAULT_IDLE_RELEASE_S+ return max(0.0, float(minutes)) * 60.0+ except Exception: # noqa: BLE001 — a config hiccup must not change residency policy+ log.debug("supervisor: idle-release setting unreadable, using the default", exc_info=True)+ return DEFAULT_IDLE_RELEASE_S+++def _brain_keep_alive(release_s: float) -> str:+ """Ollama ``keep_alive`` matching the release policy: the model lapses on+ its own once the idle window has passed; ``0`` keeps the long residency."""+ if release_s <= 0:+ return BRAIN_KEEP_ALIVE+ return f"{int(max(release_s, 60.0))}s"++# Ollama's OpenAI-compatible endpoints cannot accept a per-request context# size. Current long-context models can therefore reserve their full native# window (qwen3.5:4b used 262,144 tokens and spilled 5+ GiB into shared GPU@@ -1579,6 +1612,8 @@ def _runtime_monitor("""Detect an idle process exit promptly and a wedged pool conservatively."""next_pool_probe = time.monotonic() + RUNTIME_MONITOR_POOL_INTERVAL_Snext_brain_warm = time.monotonic() + BRAIN_REWARM_INTERVAL_S+ # A spawn means someone wanted the stack: the idle clock starts now.+ last_use_at = time.monotonic()unready_since: float | None = Noneunhealthy_kind = ""last_outcome = ""@@ -1642,11 +1677,28 @@ def _runtime_monitor(unready_since = Noneunhealthy_kind = ""last_outcome = ""+ if int(pool.get("in_use", 0)) > 0 or int(pool.get("active", 0)) > 0:+ last_use_at = now+ release_s = idle_release_s()+ if release_s > 0 and now - last_use_at >= release_s:+ # Nobody has spoken for the whole idle window: give the+ # accelerator back. The brain's keep-alive lapses by+ # itself; the next call's preflight spawns again.+ log.info(+ "local-realtime supervisor: no voice call for %d min; "+ "stopping the local voice server to free the accelerator",+ int(release_s // 60),+ )+ stop(owned_only=True)+ returnif now >= next_brain_warm:# Re-arm the brain's residency deadline on a proven- # healthy server, so an overnight gap cannot make the- # first sentence of the morning pay a cold model load.- next_brain_warm = now + BRAIN_REWARM_INTERVAL_S+ # healthy server, so a gap inside the idle window+ # cannot make the next sentence pay a cold model load.+ interval = BRAIN_REWARM_INTERVAL_S+ if release_s > 0:+ interval = min(interval, release_s / 2.0)+ next_brain_warm = now + intervalwarm_brain(launch_command=launch_command)continueif unready_since is None or unhealthy_kind != kind:@@ -2091,7 +2143,12 @@ def warm_brain(*, launch_command: str, timeout: float = 5.0) -> bool:return Falseroot = brain_url[: -len("/v1")] if brain_url.endswith("/v1") else brain_urlpayload = json.dumps(- {"model": model, "prompt": "", "keep_alive": BRAIN_KEEP_ALIVE, "stream": False}+ {+ "model": model,+ "prompt": "",+ "keep_alive": _brain_keep_alive(idle_release_s()),+ "stream": False,+ }).encode("utf-8")import urllib.errorimport urllib.request@@ -2111,7 +2168,7 @@ def warm_brain(*, launch_command: str, timeout: float = 5.0) -> bool:log.info("local-realtime supervisor: brain model %s warmed (keep_alive=%s)",model,- BRAIN_KEEP_ALIVE,+ _brain_keep_alive(idle_release_s()),)return True@@ -2132,7 +2189,9 @@ def prepare_voice_brain_command(launch_command: str, *, timeout: float = 30.0) -return launch_commandsource_model, _ = _voice_context_models(model)- context_tokens, why = voice_brain_context_tokens(root, source_model, timeout=timeout)+ context_tokens, why = voice_brain_context_tokens(+ root, source_model, timeout=timeout, override=_voice_context_override(source_model)+ )_, voice_model = _voice_context_models(source_model, context_tokens)cache_key = (root, source_model, voice_model)with _VOICE_MODEL_PREPARE_LOCK:@@ -2214,9 +2273,38 @@ def _ollama_model_facts(return size_gb, native-def voice_brain_context_tokens(root: str, model: str, *, timeout: float = 10.0) -> tuple[int, str]:+def _voice_context_override(model: str) -> int | None:+ """The ``num_ctx`` the user set for ``model`` in Local Models → Tune, or None.++ The one place a person overrides the automatic size. Stored on the Ollama+ card (``[brain.providers.ollama].models.<tag>.num_ctx``); the Tune sheet+ warns when it is above what fits, and then applies it anyway — the+ maintainer's rule is "warn, never refuse".+ """+ try:+ from jarvis.brain.ollama_inventory import same_model+ from jarvis.core.config import load_config++ providers = getattr(getattr(load_config(), "brain", None), "providers", None) or {}+ card = providers.get("ollama") if isinstance(providers, dict) else None+ models = getattr(card, "models", None) or {}+ for key, opts in models.items():+ if same_model(str(key), model):+ value = getattr(opts, "num_ctx", None)+ return int(value) if isinstance(value, int) and value > 0 else None+ except Exception: # noqa: BLE001 — an unreadable override means "automatic"+ log.debug("supervisor: voice context override unreadable for %s", model, exc_info=True)+ return None+++def voice_brain_context_tokens(+ root: str, model: str, *, timeout: float = 10.0, override: int | None = None+) -> tuple[int, str]:"""``(num_ctx, reason)`` for the managed voice brain on THIS machine.+ ``override`` (the user's own ``num_ctx`` from the Tune sheet) wins+ outright; everything below is the automatic sizing.+Budget = usable accelerator memory (dedicated VRAM, or unified memory onApple Silicon) minus :data:`VOICE_STACK_RESERVE_GB` for the local STT andTTS models; without a readable accelerator the RAM rule from@@ -2228,6 +2316,10 @@ def voice_brain_context_tokens(root: str, model: str, *, timeout: float = 10.0)from jarvis.hardware.detection import system_ram_gb, usable_accelerator_gbfloor = VOICE_BRAIN_CONTEXT_TOKENS_FLOOR+ if override is not None and override > 0:+ return int(+ override+ ), f"{model}: num_ctx {int(override):,} set by you in Local Models → Tune"size_gb, native = _ollama_model_facts(root, model, timeout=timeout)if size_gb is None:return floor, f"{model}: size unreadable from Ollama, using the {floor}-token floor"diff --git a/jarvis/ui/web/frontend/src/hooks/useLocalModels.ts b/jarvis/ui/web/frontend/src/hooks/useLocalModels.tsindex cf72c08cea..49220d622e 100644--- a/jarvis/ui/web/frontend/src/hooks/useLocalModels.ts+++ b/jarvis/ui/web/frontend/src/hooks/useLocalModels.ts@@ -122,6 +122,15 @@ export interface RoleRow {advanced: boolean;/** Sentence when the slot is served by something other than Ollama. */note: string;+ /** The voice brain's effective context on this machine (voice role only). */+ context_tokens?: number | null;+ /** "automatic" (sized from memory) | "manual" (set in Tune) | "". */+ context_source?: "" | "automatic" | "manual";+}++export interface IdleReleaseResponse {+ /** Minutes of voice idleness before the local stack frees memory; 0 = never. */+ minutes: number;}export interface RolesResponse {@@ -414,6 +423,27 @@ export async function getRoles(providerId: string): Promise<RolesResponse> {return request(`${base(providerId)}/roles`);}+export async function getIdleRelease(+ providerId: string,+): Promise<IdleReleaseResponse> {+ return request(`${base(providerId)}/runtime/idle-release`);+}++export async function setIdleRelease(+ providerId: string,+ minutes: number,+): Promise<IdleReleaseResponse> {+ return request(+ `${base(providerId)}/runtime/idle-release`,+ {+ method: "PUT",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ minutes }),+ },+ WRITE_TIMEOUT_MS,+ );+}+export async function setRole(providerId: string,role: LocalModelRole,@@ -616,6 +646,7 @@ export const localModelsKeys = {model: (p: string, name: string) =>["local-models", p, "inventory", name] as const,roles: (p: string) => ["local-models", p, "roles"] as const,+ idleRelease: (p: string) => ["local-models", p, "idle-release"] as const,options: (p: string, name: string) =>["local-models", p, "options", name] as const,suggested: (p: string, name: string) =>@@ -935,6 +966,26 @@ export function useStopServer(providerId: string | undefined) {});}+export function useIdleRelease(providerId: string | undefined) {+ return useQuery({+ queryKey: localModelsKeys.idleRelease(providerId ?? ""),+ queryFn: () => getIdleRelease(providerId as string),+ enabled: !!providerId,+ });+}++export function useSetIdleRelease(providerId: string | undefined) {+ const qc = useQueryClient();+ return useMutation({+ mutationFn: (minutes: number) => setIdleRelease(providerId as string, minutes),+ onSuccess: () => {+ void qc.invalidateQueries({+ queryKey: localModelsKeys.idleRelease(providerId ?? ""),+ });+ },+ });+}+export function useTestServer(providerId: string | undefined) {return useMutation({mutationFn: (baseUrl: string) => testServer(providerId as string, baseUrl),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 48c29d08dc..5d4bf049af 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@@ -213,7 +213,9 @@"readback_gpu": "Läuft mit {ctx} Kontext vollständig auf der Grafikkarte.","readback_ctx": "Läuft mit {ctx} Kontext.","readback_defaults": "Läuft mit den eigenen Vorgaben des Modells.",- "tune_skipped": "Zugewiesen; die Einstellungen bleiben bei den Vorgaben des Modells."+ "tune_skipped": "Zugewiesen; die Einstellungen bleiben bei den Vorgaben des Modells.",+ "voice_context_auto": "Läuft mit {context} Kontext — nach dem Speicher dieses Rechners bemessen. Über „Abstimmen“ selbst festlegen.",+ "voice_context_manual": "Läuft mit {context} Kontext — von dir unter „Abstimmen“ festgelegt."},"server": {"host_eyebrow": "Host",@@ -269,7 +271,16 @@"log_title": "Serverprotokoll","log_refresh": "Protokoll neu laden","log_loading": "Lese das Protokoll…",- "log_empty": "Noch kein Protokoll. Jarvis schreibt eines, wenn es den Server selbst startet."+ "log_empty": "Noch kein Protokoll. Jarvis schreibt eines, wenn es den Server selbst startet.",+ "idle_eyebrow": "Speicher",+ "idle_title": "Speicher bei Leerlauf freigeben",+ "idle_subtitle": "Der lokale Sprach-Stack — Voice-Server und Voice-Brain — gibt die Grafikkarte nach dieser Zeit ohne Anruf frei. Der nächste Anruf zahlt den Start erneut.",+ "idle_label": "Nach",+ "idle_minutes": "Minuten ohne Anruf",+ "idle_never": "= alles geladen lassen",+ "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."},"tune": {"aria": "{model} feinjustieren",@@ -339,7 +350,8 @@"saved_cleared": "{model} läuft wieder mit den Ollama-Standardwerten.","footnote_alias": "Läuft über das Profil {alias}; der erste Gebrauch nach einer Änderung dauert ein paar Sekunden.","footnote_will_bake": "Diese Einstellungen werden beim Speichern zu einem Profil des Modells; der erste Gebrauch danach dauert ein paar Sekunden.",- "footnote_no_alias": "Diese Einstellungen gehen mit jeder Anfrage mit; nichts wird neu gebaut."+ "footnote_no_alias": "Diese Einstellungen gehen mit jeder Anfrage mit; nichts wird neu gebaut.",+ "num_ctx_over_suggested": "Liegt laut Schätzung über dem, was in diesen Rechner passt (empfohlen {context}; das braucht etwa {estimate} GB). Wird trotzdem übernommen — das Modell kann in den Arbeitsspeicher ausweichen, langsam laufen oder nicht laden. Dein Rechner, deine Entscheidung."},"tune_missing": "Dieses Modell ist nicht mehr installiert, es gibt also nichts einzustellen."}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 ae0ec7fb30..7565b54e88 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@@ -213,7 +213,9 @@"readback_gpu": "Runs with a {ctx} context fully on the graphics card.","readback_ctx": "Runs with a {ctx} context.","readback_defaults": "Runs with the model's own defaults.",- "tune_skipped": "Assigned; the settings stay at the model's defaults."+ "tune_skipped": "Assigned; the settings stay at the model's defaults.",+ "voice_context_auto": "Runs with a {context} context — sized from this machine's memory. Tune to set it yourself.",+ "voice_context_manual": "Runs with a {context} context — set by you in Tune."},"server": {"host_eyebrow": "Host",@@ -269,7 +271,16 @@"log_title": "Server log","log_refresh": "Refresh log","log_loading": "Reading the log…",- "log_empty": "No log yet. Jarvis writes one when it starts the server itself."+ "log_empty": "No log yet. Jarvis writes one when it starts the server itself.",+ "idle_eyebrow": "Memory",+ "idle_title": "Release memory when idle",+ "idle_subtitle": "The local voice stack — its voice server and the voice brain — frees the graphics card after this long without a call. The next call pays the start-up again.",+ "idle_label": "After",+ "idle_minutes": "minutes without a call",+ "idle_never": "= keep everything loaded",+ "idle_save": "Save",+ "idle_saving": "Saving…",+ "idle_hint": "0 keeps the models loaded while Jarvis runs. Applies on the next check, no restart needed."},"tune": {"aria": "Tune {model}",@@ -339,7 +350,8 @@"saved_cleared": "{model} runs on Ollama's defaults again.","footnote_alias": "Runs through the profile {alias}; the first use after a change takes a few seconds.","footnote_will_bake": "These settings become a profile of the model on save; the first use afterwards takes a few seconds.",- "footnote_no_alias": "These settings go with each request; nothing is rebuilt."+ "footnote_no_alias": "These settings go with each request; nothing is rebuilt.",+ "num_ctx_over_suggested": "Above what fits this machine by estimate (suggested {context}; this needs roughly {estimate} GB). It will still be applied — the model may spill into system memory, run slowly or fail to load. Your machine, your call."},"tune_missing": "That model is no longer installed, so there is nothing to tune."}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 7606c84271..abbd2630eb 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@@ -213,7 +213,9 @@"readback_gpu": "Corre con un contexto de {ctx} por completo en la tarjeta gráfica.","readback_ctx": "Corre con un contexto de {ctx}.","readback_defaults": "Corre con los valores propios del modelo.",- "tune_skipped": "Asignado; los ajustes se quedan en los valores del modelo."+ "tune_skipped": "Asignado; los ajustes se quedan en los valores del modelo.",+ "voice_context_auto": "Funciona con un contexto de {context}, dimensionado según la memoria de este equipo. Ajústalo tú en «Ajustar».",+ "voice_context_manual": "Funciona con un contexto de {context}, fijado por ti en «Ajustar»."},"server": {"host_eyebrow": "Host",@@ -269,7 +271,16 @@"log_title": "Registro del servidor","log_refresh": "Recargar el registro","log_loading": "Leyendo el registro…",- "log_empty": "Aún no hay registro. Jarvis escribe uno cuando inicia el servidor por sí mismo."+ "log_empty": "Aún no hay registro. Jarvis escribe uno cuando inicia el servidor por sí mismo.",+ "idle_eyebrow": "Memoria",+ "idle_title": "Liberar memoria en reposo",+ "idle_subtitle": "La pila de voz local (su servidor de voz y el cerebro de voz) libera la tarjeta gráfica tras este tiempo sin llamadas. La siguiente llamada vuelve a pagar el arranque.",+ "idle_label": "Tras",+ "idle_minutes": "minutos sin llamada",+ "idle_never": "= mantener todo cargado",+ "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."},"tune": {"aria": "Ajustar {model}",@@ -339,7 +350,8 @@"saved_cleared": "{model} vuelve a usar los valores predeterminados de Ollama.","footnote_alias": "Se ejecuta a través del perfil {alias}; el primer uso tras un cambio tarda unos segundos.","footnote_will_bake": "Estos ajustes se convierten en un perfil del modelo al guardar; el primer uso después tarda unos segundos.",- "footnote_no_alias": "Estos ajustes van con cada solicitud; no se reconstruye nada."+ "footnote_no_alias": "Estos ajustes van con cada solicitud; no se reconstruye nada.",+ "num_ctx_over_suggested": "Según la estimación supera lo que cabe en este equipo (sugerido {context}; esto necesita unos {estimate} GB). Se aplicará igualmente: el modelo puede pasar a la memoria del sistema, ir lento o no cargar. Tu equipo, tu decisión."},"tune_missing": "Ese modelo ya no está instalado, así que no hay nada que ajustar."}diff --git a/jarvis/ui/web/frontend/src/views/local-models/RolesPanel.tsx b/jarvis/ui/web/frontend/src/views/local-models/RolesPanel.tsxindex bf8b0dbb34..0896a04813 100644--- a/jarvis/ui/web/frontend/src/views/local-models/RolesPanel.tsx+++ b/jarvis/ui/web/frontend/src/views/local-models/RolesPanel.tsx@@ -500,6 +500,21 @@ function RoleLedgerRow({</span>))}</div>+ {row.id === "voice" && row.context_tokens ? (+ <p+ className="mt-1 text-xs text-muted-foreground"+ data-testid="voice-context"+ >+ {fill(+ t(+ row.context_source === "manual"+ ? "local_models.roles.voice_context_manual"+ : "local_models.roles.voice_context_auto",+ ),+ { context: contextLabel(row.context_tokens) },+ )}+ </p>+ ) : null}<div className="mt-1 text-sm">{row.current ? (<StatusDotdiff --git a/jarvis/ui/web/frontend/src/views/local-models/ServerPanel.tsx b/jarvis/ui/web/frontend/src/views/local-models/ServerPanel.tsxindex c0d8c351b9..7222d22496 100644--- a/jarvis/ui/web/frontend/src/views/local-models/ServerPanel.tsx+++ b/jarvis/ui/web/frontend/src/views/local-models/ServerPanel.tsx@@ -42,7 +42,9 @@ import {} from "@/components/providers/ProviderTierSection";import {useEnvGuide,+ useIdleRelease,useServer,+ useSetIdleRelease,useServerLog,useStopServer,useTestServer,@@ -99,6 +101,66 @@ function guessOs(): EnvGuideOs | undefined {return undefined;}+/**+ * Minutes of voice idleness before the local voice stack frees the+ * accelerator (0 = keep loaded). Saved on click; the supervisor reads it on+ * its next tick, no restart.+ */+function IdleReleaseControl({ providerId }: { providerId: string }) {+ const t = useT();+ const current = useIdleRelease(providerId);+ const save = useSetIdleRelease(providerId);+ const [draft, setDraft] = useState<string>("");+ useEffect(() => {+ if (current.data) setDraft(String(current.data.minutes));+ }, [current.data]);+ const minutes = Number.parseInt(draft, 10);+ const valid = Number.isFinite(minutes) && minutes >= 0 && minutes <= 1440;+ const dirty = current.data ? minutes !== current.data.minutes : false;+ return (+ <div className="space-y-2" data-testid="idle-release">+ <div className="flex flex-wrap items-center gap-2">+ <label className="text-sm text-foreground" htmlFor="idle-release-minutes">+ {t("local_models.server.idle_label")}+ </label>+ <input+ id="idle-release-minutes"+ type="number"+ min={0}+ max={1440}+ step={5}+ value={draft}+ onChange={(e) => setDraft(e.target.value)}+ className="w-24 rounded-md border border-border bg-background px-2 py-1 text-sm text-foreground"+ aria-label={t("local_models.server.idle_label")}+ />+ <span className="text-xs text-muted-foreground">+ {minutes === 0+ ? t("local_models.server.idle_never")+ : t("local_models.server.idle_minutes")}+ </span>+ <SoftButton+ onClick={() => save.mutate(minutes)}+ disabled={!valid || !dirty || save.isPending}+ ariaLabel={t("local_models.server.idle_save")}+ >+ {save.isPending+ ? t("local_models.server.idle_saving")+ : t("local_models.server.idle_save")}+ </SoftButton>+ </div>+ <p className="text-xs text-muted-foreground">+ {t("local_models.server.idle_hint")}+ </p>+ {save.isError && (+ <p className="text-sm text-destructive" role="alert">+ {save.error instanceof Error ? save.error.message : String(save.error)}+ </p>+ )}+ </div>+ );+}+export function ServerPanel({ providerId }: { providerId: string }) {const t = useT();const pushToast = useEventStore((s) => s.pushToast);@@ -348,6 +410,20 @@ export function ServerPanel({ providerId }: { providerId: string }) {</div></Panel>+ {/* Memory release --------------------------------------------------------- */}+ {!remote && (+ <Panel>+ <div className="space-y-3 p-4">+ <p className={EYEBROW}>{t("local_models.server.idle_eyebrow")}</p>+ <PanelHeader+ title={t("local_models.server.idle_title")}+ subtitle={t("local_models.server.idle_subtitle")}+ />+ <IdleReleaseControl providerId={providerId} />+ </div>+ </Panel>+ )}+{/* Loaded now ------------------------------------------------------------ */}<Panel><div className="p-4 pb-2">diff --git a/jarvis/ui/web/frontend/src/views/local-models/TuneSheet.tsx b/jarvis/ui/web/frontend/src/views/local-models/TuneSheet.tsxindex 76d7fd162f..9e4eb63e42 100644--- a/jarvis/ui/web/frontend/src/views/local-models/TuneSheet.tsx+++ b/jarvis/ui/web/frontend/src/views/local-models/TuneSheet.tsx@@ -203,6 +203,15 @@ export function TuneSheet({ providerId, model, onClose }: TuneSheetProps) {return list;}, [native]);+ // The user may go above what fits this machine — with a warning, never a+ // refusal (maintainer rule 2026-08-24: their machine, their call).+ const suggestedCtx = suggested.data?.options.num_ctx ?? null;+ const overSuggested =+ suggestedCtx !== null &&+ suggestedCtx !== undefined &&+ typeof draft.num_ctx === "number" &&+ draft.num_ctx > suggestedCtx;+const set = <K extends keyof OllamaModelOptions>(key: K,value: OllamaModelOptions[K],@@ -364,6 +373,17 @@ export function TuneSheet({ providerId, model, onClose }: TuneSheetProps) {</Chip>))}</Knob>+ {overSuggested && typeof draft.num_ctx === "number" && (+ <p+ className="text-xs text-amber-600 dark:text-amber-400"+ data-testid="tune-ctx-warning"+ >+ {fill(k("num_ctx_over_suggested"), {+ context: formatContext(suggestedCtx as number),+ estimate: estimateContextGb(draft.num_ctx, modelGb).toFixed(1),+ })}+ </p>+ )}</div>{/* Placement */}diff --git a/jarvis/ui/web/local_models_routes.py b/jarvis/ui/web/local_models_routes.pyindex 7bd73f26e7..78157dc29d 100644--- a/jarvis/ui/web/local_models_routes.py+++ b/jarvis/ui/web/local_models_routes.py@@ -47,6 +47,7 @@ from jarvis.brain.ollama_inventory import (same_model,)from jarvis.core import config as cfg_mod+from jarvis.core import config_writerfrom jarvis.core.config import OLLAMA_MODEL_OPTION_KEYS, OllamaModelOptionsfrom jarvis.ui.web.provider_routes import _require_pull_capable, _resolve_cfg@@ -381,6 +382,10 @@ class RoleRow(BaseModel):advanced: bool#: One sentence when the slot is served by something other than Ollama.note: str = ""+ #: The voice brain's effective context on this machine (voice role only).+ context_tokens: int | None = None+ #: "automatic" | "manual" | "".+ context_source: str = ""class RolesResponse(BaseModel):@@ -418,6 +423,8 @@ def _role_row(state: ollama_roles.RoleState) -> RoleRow:writable=spec.writable,advanced=spec.advanced,note=state.note,+ context_tokens=state.context_tokens,+ context_source=state.context_source,)@@ -848,6 +855,39 @@ async def post_server_stop(provider_id: str) -> ServerActionResponse:return ServerActionResponse(ok=ok, message=message)+class IdleReleaseBody(BaseModel):+ #: Minutes of voice idleness before the local stack frees the accelerator; 0 = never.+ minutes: int = Field(ge=0, le=1440)+++class IdleReleaseResponse(BaseModel):+ minutes: int++[email protected]("/runtime/idle-release", response_model=IdleReleaseResponse)+async def get_idle_release(provider_id: str, request: Request) -> IdleReleaseResponse:+ """How long the local voice stack may sit idle before it releases memory."""+ _require_pull_capable(provider_id)+ voice = getattr(_resolve_cfg(request), "voice", None)+ return IdleReleaseResponse(minutes=int(getattr(voice, "local_idle_release_minutes", 30)))++[email protected]("/runtime/idle-release", response_model=IdleReleaseResponse)+async def put_idle_release(+ provider_id: str, body: IdleReleaseBody, request: Request+) -> IdleReleaseResponse:+ """Persist the idle window; the supervisor reads it on its next tick."""+ _require_pull_capable(provider_id)+ config_writer.set_local_idle_release_minutes(body.minutes)+ voice = getattr(_resolve_cfg(request), "voice", None)+ if voice is not None:+ try:+ voice.local_idle_release_minutes = int(body.minutes)+ except Exception: # noqa: BLE001 — a frozen in-memory config still got the TOML write+ log.debug("local-models: in-memory idle-release update skipped", exc_info=True)+ return IdleReleaseResponse(minutes=int(body.minutes))++@router.post("/server/test", response_model=ServerProbeResponse)async def post_server_test(provider_id: str, body: ServerTestBody) -> ServerProbeResponse:"""Probe a host before saving it: version and latency, or the reason it failed."""diff --git a/tests/unit/brain/test_ollama_roles.py b/tests/unit/brain/test_ollama_roles.pyindex 94c0ed7172..8c8bae557c 100644--- a/tests/unit/brain/test_ollama_roles.py+++ b/tests/unit/brain/test_ollama_roles.py@@ -268,3 +268,23 @@ def test_roles_using_is_latest_tolerant() -> None:cfg.brain.providers["ollama"].model = "gemma4"assert ollama_roles.roles_using(cfg, "gemma4:latest") == ["chat"]assert ollama_roles.roles_using(cfg, "qwen3-embedding:4b") == ["embedding"]+++# -- Idle release + the user's own choice --+++async def test_voice_context_reports_where_the_size_came_from(monkeypatch) -> None:+ from jarvis.realtime.local_server import supervisor++ monkeypatch.setattr(supervisor, "_voice_context_override", lambda model: None)+ monkeypatch.setattr(+ supervisor,+ "voice_brain_context_tokens",+ lambda root, model, timeout, override: (65_536, "auto"),+ )+ assert await ollama_roles.voice_context(_cfg(), "qwen3.5:4b") == (65_536, "automatic")+ monkeypatch.setattr(supervisor, "_voice_context_override", lambda model: 16_384)+ assert (await ollama_roles.voice_context(_cfg(), "qwen3.5:4b"))[1] == "manual"+ # No launch command -> no root -> no guess.+ assert await ollama_roles.voice_context(JarvisConfig(), "qwen3.5:4b") == (None, "")diff --git a/tests/unit/core/test_config_writer_local_idle_release.py b/tests/unit/core/test_config_writer_local_idle_release.pynew file mode 100644index 0000000000..c9b31de142--- /dev/null+++ b/tests/unit/core/test_config_writer_local_idle_release.py@@ -0,0 +1,23 @@+"""``[voice] local_idle_release_minutes`` — the local voice stack's idle window."""++from __future__ import annotations++import tomllib++from jarvis.core.config_writer import set_local_idle_release_minutes+++def _minutes(path) -> int:+ return tomllib.loads(path.read_text(encoding="utf-8"))["voice"]["local_idle_release_minutes"]+++def test_idle_release_is_written_under_voice(tmp_path) -> None:+ path = tmp_path / "jarvis.toml"+ path.write_text('[voice]\nmode = "realtime"\n', encoding="utf-8")++ set_local_idle_release_minutes(45, path=path)+ block = tomllib.loads(path.read_text(encoding="utf-8"))["voice"]+ assert block == {"mode": "realtime", "local_idle_release_minutes": 45}++ set_local_idle_release_minutes(-3, path=path)+ assert _minutes(path) == 0diff --git a/tests/unit/realtime/local_server/test_supervisor.py b/tests/unit/realtime/local_server/test_supervisor.pyindex 0bf9a6213e..9f2b762b88 100644--- a/tests/unit/realtime/local_server/test_supervisor.py+++ b/tests/unit/realtime/local_server/test_supervisor.py@@ -1713,6 +1713,9 @@ def test_cloud_brain_command_is_not_rewritten(monkeypatch) -> None:def test_warm_brain_pings_ollama_with_keep_alive(monkeypatch) -> None:import urllib.request+ # keep_alive follows the idle-release window; 0 = the long residency.+ monkeypatch.setattr(supervisor, "idle_release_s", lambda: 0.0)+requests: list[tuple[str, dict[str, Any]]] = []class _Response:diff --git a/tests/unit/realtime/local_server/test_voice_brain_context.py b/tests/unit/realtime/local_server/test_voice_brain_context.pyindex 71b12d0b1c..b2c6f980ea 100644--- a/tests/unit/realtime/local_server/test_voice_brain_context.py+++ b/tests/unit/realtime/local_server/test_voice_brain_context.py@@ -138,3 +138,117 @@ def test_inventory_hides_every_voice_alias_size() -> None:assert ollama_inventory.is_hidden_alias("qwen3.5:4b-voice-8k")assert ollama_inventory.is_hidden_alias("qwen3.5:4b-voice-64k:latest")assert not ollama_inventory.is_hidden_alias("qwen3.5:4b")+++# -- Idle release + the user's own choice --+++def test_the_users_tune_choice_wins_over_the_automatic_size(monkeypatch) -> None:+ _fake_ollama(monkeypatch, size_bytes=3_400_000_000, native=262_144, created=[])+ monkeypatch.setattr(+ "jarvis.hardware.detection.usable_accelerator_gb", lambda: (15.9, "nvidia-smi")+ )+ tokens, why = supervisor.voice_brain_context_tokens(+ "http://127.0.0.1:11434", "qwen3.5:4b", override=131_072+ )+ assert tokens == 131_072+ assert "set by you" in why+++def test_prepare_reads_the_override_from_the_ollama_card(monkeypatch) -> None:+ created: list[dict] = []+ _fake_ollama(monkeypatch, size_bytes=3_400_000_000, native=262_144, created=created)+ monkeypatch.setattr(supervisor, "_voice_context_override", lambda model: 32_768)+ command = (+ "python -m server --model_name qwen3.5:4b "+ "--responses_api_base_url http://127.0.0.1:11434/v1 --responses_api_api_key ollama"+ )+ out = supervisor.prepare_voice_brain_command(command)+ assert "qwen3.5:4b-voice-32k" in out+ assert created[0]["parameters"] == {"num_ctx": 32_768}+++def test_override_is_the_tune_num_ctx_of_the_base_model(monkeypatch) -> None:+ from jarvis.core.config import BrainProviderConfig, JarvisConfig, OllamaModelOptions++ cfg = JarvisConfig()+ cfg.brain.providers["ollama"] = BrainProviderConfig(+ models={"qwen3.5:4b": OllamaModelOptions(num_ctx=16_384)}+ )+ monkeypatch.setattr("jarvis.core.config.load_config", lambda: cfg)+ assert supervisor._voice_context_override("qwen3.5:4b") == 16_384+ assert supervisor._voice_context_override("qwen3.5:4b-voice-8k") is None+ assert supervisor._voice_context_override("other:1b") is None+++def test_keep_alive_follows_the_idle_window() -> None:+ assert supervisor._brain_keep_alive(0) == supervisor.BRAIN_KEEP_ALIVE+ assert supervisor._brain_keep_alive(1800) == "1800s"+ assert supervisor._brain_keep_alive(10) == "60s"+++def test_idle_release_reads_the_voice_setting(monkeypatch) -> None:+ from jarvis.core.config import JarvisConfig++ cfg = JarvisConfig()+ assert cfg.voice.local_idle_release_minutes == 30+ cfg.voice.local_idle_release_minutes = 5+ monkeypatch.setattr("jarvis.core.config.load_config", lambda: cfg)+ assert supervisor.idle_release_s() == 300.0+ cfg.voice.local_idle_release_minutes = 0+ assert supervisor.idle_release_s() == 0.0+++def _monitor_setup(monkeypatch, tmp_path, pool: dict) -> list[str]:+ import threading++ root = tmp_path / "local_realtime"+ command = f'"{root / "server.exe"}" --mode realtime'+ monkeypatch.setattr(supervisor, "RUNTIME_MONITOR_POLL_S", 0.0)+ monkeypatch.setattr(supervisor, "RUNTIME_MONITOR_POOL_INTERVAL_S", 0.0)+ monkeypatch.setattr(supervisor, "managed_install_root", lambda value: root)+ monkeypatch.setattr(supervisor, "_owned_process", lambda: (4711, True))+ monkeypatch.setattr(+ supervisor,+ "_revive_from_monitor",+ lambda **kwargs: pytest.fail("a healthy server must never be revived"),+ )+ monkeypatch.setattr(supervisor, "warm_brain", lambda **kwargs: True)+ stopped: list[str] = []+ stop_event = threading.Event()+ probes = {"n": 0}++ def probe(*args, **kwargs):+ import time++ probes["n"] += 1+ if probes["n"] == 1:+ # Windows' monotonic clock ticks every ~16 ms; let the idle window pass.+ time.sleep(0.05)+ if probes["n"] >= 25:+ stop_event.set()+ return pool++ monkeypatch.setattr(supervisor, "probe_runtime", probe)++ def stop(*, owned_only: bool = True, install_root=None):+ stopped.append("stopped")+ stop_event.set()+ return True, "stopped"++ monkeypatch.setattr(supervisor, "stop", stop)+ monkeypatch.setattr(supervisor, "idle_release_s", lambda: 0.001)+ supervisor._runtime_monitor(+ command, "http://127.0.0.1:8765", stop_event, (command, "http://127.0.0.1:8765/v1/pool")+ )+ return stopped+++def test_monitor_stops_the_server_after_the_idle_window(monkeypatch, tmp_path) -> None:+ idle = {"size": 1, "in_use": 0, "available": 1, "active": 0, "draining": 0, "stuck": 0}+ assert _monitor_setup(monkeypatch, tmp_path, idle) == ["stopped"]+++def test_monitor_keeps_the_server_while_a_call_is_active(monkeypatch, tmp_path) -> None:+ busy = {"size": 1, "in_use": 1, "available": 0, "active": 1, "draining": 0, "stuck": 0}+ assert _monitor_setup(monkeypatch, tmp_path, busy) == []diff --git a/tests/unit/ui/web/test_local_models_routes.py b/tests/unit/ui/web/test_local_models_routes.pyindex d0c92297f7..19648563b3 100644--- a/tests/unit/ui/web/test_local_models_routes.py+++ b/tests/unit/ui/web/test_local_models_routes.py@@ -579,3 +579,43 @@ def test_server_stop_carries_the_danger_flag() -> None:if (getattr(route, "openapi_extra", None) or {}).get("x-jarvis-dangerous")}assert f"{BASE.replace('ollama', '{provider_id}')}/server/stop" in flagged+++# -- Idle release + the user's own choice --+++def test_idle_release_round_trip(server: WebServer, fake, monkeypatch) -> None:+ written: list[int] = []+ monkeypatch.setattr(+ config_writer, "set_local_idle_release_minutes", lambda minutes: written.append(minutes)+ )+ with TestClient(server.app) as client:+ assert client.get(f"{BASE}/runtime/idle-release").json() == {"minutes": 30}+ assert client.put(f"{BASE}/runtime/idle-release", json={"minutes": 0}).json() == {+ "minutes": 0+ }+ assert written == [0]+ assert client.get(f"{BASE}/runtime/idle-release").json() == {"minutes": 0}+ assert client.put(f"{BASE}/runtime/idle-release", json={"minutes": -1}).status_code == 422+++def test_roles_carry_the_voice_brains_context(server: WebServer, fake, monkeypatch) -> None:+ from jarvis.brain import ollama_roles++ server.app.state.config.brain.providers["local-realtime"] = BrainProviderConfig(+ launch_command=(+ "python -m server --model_name qwen3.5:4b "+ "--responses_api_base_url http://127.0.0.1:11434/v1"+ )+ )++ async def sized(cfg, model):+ return 65_536, "automatic"++ monkeypatch.setattr(ollama_roles, "voice_context", sized)+ with TestClient(server.app) as client:+ rows = {r["id"]: r for r in client.get(f"{BASE}/roles").json()["roles"]}+ assert rows["voice"]["context_tokens"] == 65_536+ assert rows["voice"]["context_source"] == "automatic"+ assert rows["chat"]["context_tokens"] is None+ assert rows["chat"]["context_source"] == ""