Skip to content

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.

fix(providers): stop reporting a loading local model as broken

rubenluetke10-beepf8eec7b0388d
diff --git a/jarvis/ui/web/frontend/src/components/BrainModelSelector.tsx b/jarvis/ui/web/frontend/src/components/BrainModelSelector.tsx
index 14c6d58bcb..ce8e0adec3 100644
--- a/jarvis/ui/web/frontend/src/components/BrainModelSelector.tsx
+++ b/jarvis/ui/web/frontend/src/components/BrainModelSelector.tsx
@@ -200,6 +200,11 @@ export function BrainModelSelector({
const [saving, setSaving] = useState(false);
const [pinned, setPinned] = useState<string>(currentModel ?? "");
const [probe, setProbe] = useState<BrainModelProbe | null>(null);
+ // A save runs a real 1-token call against the chosen model, and the FIRST
+ // call to a local model loads gigabytes of weights into memory — measured at
+ // over a minute for a 30B model. A silent spinner for that long reads as a
+ // hang, so after a few seconds the wait explains itself.
+ const [slowProbe, setSlowProbe] = useState(false);
async function load(refresh = false) {
setLoading(true);
@@ -320,6 +325,8 @@ export function BrainModelSelector({
async function save(value: string) {
const model = value.trim();
setSaving(true);
+ setSlowProbe(false);
+ const slowTimer = window.setTimeout(() => setSlowProbe(true), 6000);
setProbe(null);
setOpen(false);
setQuery("");
@@ -370,6 +377,8 @@ export function BrainModelSelector({
}
pushToast("error", (e as Error).message);
} finally {
+ window.clearTimeout(slowTimer);
+ setSlowProbe(false);
setSaving(false);
}
}
@@ -623,6 +632,14 @@ export function BrainModelSelector({
<span className="text-[11px] text-muted-foreground">{sourceNote}</span>
)}
{probe && <ProbeChip probe={probe} />}
+ {slowProbe && (
+ <span
+ data-testid="brain-model-probe-slow"
+ className="text-[11px] text-muted-foreground"
+ >
+ {t("apikeys_model.probe_slow_note")}
+ </span>
+ )}
</div>
</div>
);
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 1242b7e1e7..182975b6ed 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -1339,7 +1339,8 @@
"filter_hint_starred": "Handverlesene Top-Modelle.",
"filter_hint_free": "Kostenlose Modelle — kein API-Guthaben nötig.",
"filter_hint_frontier": "Wenn der Preis egal ist — die leistungsstärksten Modelle.",
- "filter_hint_value": "Die beste Leistung fürs Geld."
+ "filter_hint_value": "Die beste Leistung fürs Geld.",
+ "probe_slow_note": "Wird noch geprüft — beim ersten Aufruf lädt ein großes lokales Modell in den Speicher, das kann Minuten dauern."
},
"apikeys_voice": {
"heading": "Stimme",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index f7c9f8227f..5ffa135b4e 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -1339,7 +1339,8 @@
"filter_hint_starred": "Hand-picked best models.",
"filter_hint_free": "Zero-cost models — no API credit needed.",
"filter_hint_frontier": "When price doesn't matter — the most capable models.",
- "filter_hint_value": "The best performance for the price."
+ "filter_hint_value": "The best performance for the price.",
+ "probe_slow_note": "Still checking — the first call to a large local model loads it into memory and can take minutes."
},
"apikeys_voice": {
"heading": "Voice",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 3b325797b8..4a458cba93 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -1339,7 +1339,8 @@
"filter_hint_starred": "Los mejores modelos, elegidos a mano.",
"filter_hint_free": "Modelos gratuitos — sin necesidad de crédito de API.",
"filter_hint_frontier": "Cuando el precio no importa — los modelos más capaces.",
- "filter_hint_value": "La mejor relación calidad-precio."
+ "filter_hint_value": "La mejor relación calidad-precio.",
+ "probe_slow_note": "Comprobando todavía: la primera llamada a un modelo local grande lo carga en memoria y puede tardar minutos."
},
"apikeys_voice": {
"heading": "Voz",
diff --git a/jarvis/ui/web/provider_routes.py b/jarvis/ui/web/provider_routes.py
index 53e47e462d..50f91b68a4 100644
--- a/jarvis/ui/web/provider_routes.py
+++ b/jarvis/ui/web/provider_routes.py
@@ -1200,10 +1200,29 @@ async def list_providers(request: Request) -> dict[str, Any]:
# Belt-and-suspenders ceiling for the whole /test call. run_provider_test's own
# timeout_s (60 s, generous for NVIDIA NIM's 13-30 s cold-start TTFB) bounds the
-# individual probe; this outer bound guarantees the HTTP response itself.
+# individual probe; this outer bound guarantees the HTTP response itself. Local
+# cards raise BOTH (see _tier_test_budget_s) — their first call loads weights.
+_DEFAULT_TIER_TEST_S = 60.0
_PROVIDER_TEST_HARD_TIMEOUT_S = 75.0
+def _tier_test_budget_s(spec: ProviderSpec) -> float:
+ """Per-call budget for the Test button; local cards get the load allowance.
+
+ The local STT path already did this (a cold on-device recognizer gets 180 s
+ there); a local BRAIN needs it for the same reason, and without it a large
+ downloaded model reported as broken while it was merely loading.
+ """
+ if spec.auth_mode == "none":
+ return _LOCAL_MODEL_PROBE_S
+ return _DEFAULT_TIER_TEST_S
+
+
+def _tier_test_ceiling_s(spec: ProviderSpec) -> float:
+ """Hard route ceiling: always above the per-call budget it bounds."""
+ return _tier_test_budget_s(spec) + 15.0
+
+
async def _run_tier_test(
spec: ProviderSpec, cfg: Any, *, model: str | None = None
) -> Any:
@@ -1256,7 +1275,9 @@ async def _run_tier_test(
return await _provider_test.run_provider_test(
spec, cfg, codex_status=lambda: isolated_status, model=model
)
- return await _provider_test.run_provider_test(spec, cfg, model=model)
+ return await _provider_test.run_provider_test(
+ spec, cfg, model=model, timeout_s=_tier_test_budget_s(spec)
+ )
@router.post("/providers/{provider_id}/test")
@@ -1282,24 +1303,21 @@ async def test_provider_connection(
status_code=503, detail="Configuration is unavailable (headless mode?)"
)
- # Hard ceiling ABOVE run_provider_test's own per-call timeout (60 s): the
- # route must always answer, else the UI's "Testing…" spinner never resolves.
- # Any async path that slips past the inner bounds is cut here and reported
- # as an honest "unreachable" instead of a hung HTTP request.
+ # Hard ceiling ABOVE the per-call timeout the tier uses: the route must
+ # always answer, else the UI's "Testing…" spinner never resolves. Any async
+ # path that slips past the inner bounds is cut here and reported as an
+ # honest "unreachable" instead of a hung HTTP request.
+ ceiling = _tier_test_ceiling_s(spec)
try:
- result = await asyncio.wait_for(
- _run_tier_test(spec, cfg),
- timeout=_PROVIDER_TEST_HARD_TIMEOUT_S,
- )
+ result = await asyncio.wait_for(_run_tier_test(spec, cfg), timeout=ceiling)
except TimeoutError:
result = _provider_test.ProviderTestResult(
provider=spec.id,
status=_provider_test.UNREACHABLE,
detail=(
- f"Test timed out after {_PROVIDER_TEST_HARD_TIMEOUT_S:.0f}s — "
- "the provider did not answer."
+ f"Test timed out after {ceiling:.0f}s — the provider did not answer."
),
- latency_ms=_PROVIDER_TEST_HARD_TIMEOUT_S * 1000.0,
+ latency_ms=ceiling * 1000.0,
)
# This exact result is newer than any overlapping section sweep. Cancel the
# older snapshot so the UI refresh cannot resurrect a pre-test status.
@@ -2115,8 +2133,33 @@ def _set_cu_model_in_memory(cfg: Any, provider: str, value: str) -> None:
log.debug("In-memory cu_model update skipped for %s: %s", provider, exc)
+#: Cloud model probe: a hosted model answers a 1-token prompt in seconds, and a
+#: longer wait would just delay an honest "this key cannot use that model".
+_CLOUD_MODEL_PROBE_S = 20.0
+
+#: Local model probe: the FIRST call to a local model loads its weights off disk
+#: into memory, and an 18 GB download needs over a minute for that on a normal
+#: machine (measured 2026-08-05: 70 s for a 30B model on a 32 GB box). Under the
+#: cloud budget every large local model tested as broken while being perfectly
+#: fine — the probe was timing the load, not the model.
+_LOCAL_MODEL_PROBE_S = 240.0
+
+
+def _model_probe_budget_s(provider: str) -> float:
+ """Probe budget for ``provider``: a load-from-disk allowance for local cards.
+
+ Locality comes from the card's auth mode — a keyless server the user runs
+ themselves — the same definition the brain resolver uses for its local tail,
+ never a provider name (AP-21).
+ """
+ spec = get_spec(provider)
+ if spec is not None and spec.auth_mode == "none":
+ return _LOCAL_MODEL_PROBE_S
+ return _CLOUD_MODEL_PROBE_S
+
+
async def _probe_brain_model(
- provider: str, model: str, *, timeout_s: float = 20.0
+ provider: str, model: str, *, timeout_s: float | None = None
) -> _provider_test.ProviderTestResult:
"""Run a REAL 1-token call against the *specific* ``model`` and classify it.
@@ -2124,12 +2167,16 @@ async def _probe_brain_model(
model), this validates the model the user just selected — so a typo or a
model the key has no access to comes back as ``model_unavailable`` rather
than silently "saved but broken". Module-level so it is monkeypatchable.
+
+ ``timeout_s`` defaults to a per-card budget: a local server is allowed the
+ minutes its first call spends loading weights, a hosted one is not.
"""
from jarvis.brain.healthcheck import BrainHealthChecker
from jarvis.brain.provider_registry import BrainProviderRegistry
+ budget = timeout_s if timeout_s is not None else _model_probe_budget_s(provider)
checker = BrainHealthChecker(BrainProviderRegistry())
- hr = await checker.probe(provider, model, timeout_s=timeout_s)
+ hr = await checker.probe(provider, model, timeout_s=budget)
if getattr(hr, "ok", False):
return _provider_test.ProviderTestResult(
provider, _provider_test.OK, "", getattr(hr, "duration_ms", 0.0)
@@ -2138,11 +2185,34 @@ async def _probe_brain_model(
return _provider_test.ProviderTestResult(
provider,
_provider_test.classify_provider_error(err),
- err or "",
+ _model_probe_detail(provider, model, err, budget),
getattr(hr, "duration_ms", 0.0),
)
+def _model_probe_detail(
+ provider: str, model: str, error: str | None, budget: float
+) -> str:
+ """The sentence the card shows — "timeout after 240.0s" explains nothing.
+
+ A local model that times out is almost always still loading, and the user's
+ next step ("wait, or pick a smaller model") is completely different from the
+ one a dead endpoint calls for. Every other error keeps the provider's own
+ words, which are usually more precise than anything we could add.
+ """
+ raw = error or ""
+ spec = get_spec(provider)
+ is_local = spec is not None and spec.auth_mode == "none"
+ if is_local and "timeout" in raw.lower():
+ return (
+ f"{model} did not answer within {budget:.0f}s. A local model is "
+ "loaded into memory on its first call, and a large one can take "
+ "minutes — leave it loading and test again, or choose a smaller "
+ "model."
+ )
+ return raw
+
+
def _require_catalog_provider(provider_id: str):
"""Validate that ``provider_id`` has a model/voice catalog.
diff --git a/tests/integration/test_provider_model_routes.py b/tests/integration/test_provider_model_routes.py
index 4794662249..5ec50da635 100644
--- a/tests/integration/test_provider_model_routes.py
+++ b/tests/integration/test_provider_model_routes.py
@@ -489,3 +489,50 @@ def test_post_tts_preview_rejects_other_provider(server: WebServer) -> None:
"/api/tts/preview", json={"provider": "grok-voice", "language": "en"}
)
assert resp.status_code == 400
+
+
+# ── Probe budgets: a local model's first call LOADS it ───────────────────────
+
+
+def test_local_card_gets_a_load_from_disk_probe_budget() -> None:
+ """Measured 2026-08-05: a 30B model's first call took 70 s on a 32 GB box —
+ pure load-from-disk time. Under the cloud budget the probe was timing the
+ LOAD, not the model, and every large local model tested as broken."""
+ from jarvis.ui.web import provider_routes as pr
+
+ assert pr._model_probe_budget_s("ollama") >= 120.0
+ assert pr._model_probe_budget_s("local-openai") >= 120.0
+ # A hosted model answers in seconds; a longer wait would only delay the
+ # honest "this key cannot use that model".
+ assert pr._model_probe_budget_s("gemini") == pr._CLOUD_MODEL_PROBE_S
+ assert pr._model_probe_budget_s("openai") == pr._CLOUD_MODEL_PROBE_S
+
+
+def test_local_probe_timeout_explains_itself() -> None:
+ """"timeout after 240.0s" tells the user nothing about what to do next."""
+ from jarvis.ui.web import provider_routes as pr
+
+ detail = pr._model_probe_detail(
+ "ollama", "qwen3-coder:30b", "timeout after 240.0s", 240.0
+ )
+ assert "loaded into memory" in detail
+ assert "qwen3-coder:30b" in detail
+ # Every other error keeps the provider's own, more precise words.
+ assert pr._model_probe_detail("ollama", "m", "404 model not found", 240.0) == (
+ "404 model not found"
+ )
+ assert pr._model_probe_detail("gemini", "m", "timeout after 20.0s", 20.0) == (
+ "timeout after 20.0s"
+ )
+
+
+def test_test_button_ceiling_stays_above_its_own_budget() -> None:
+ """The route ceiling exists to guarantee an HTTP answer; a ceiling BELOW
+ the per-call budget would cut every slow local test at the wrong layer."""
+ from jarvis.ui.web import provider_routes as pr
+ from jarvis.ui.web.provider_spec import get_spec
+
+ for provider_id in ("ollama", "gemini", "piper-local"):
+ spec = get_spec(provider_id)
+ assert spec is not None
+ assert pr._tier_test_ceiling_s(spec) > pr._tier_test_budget_s(spec)