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(providers): live-honest Sub-Agents section health (degraded vs no-provider)
Ruben Lütkea59a69f54a1a
diff --git a/jarvis/missions/init.py b/jarvis/missions/init.pyindex ea84eb3bb8..4b140258a3 100644--- a/jarvis/missions/init.py+++ b/jarvis/missions/init.py@@ -492,6 +492,35 @@ def _claude_cli_auth_viable() -> bool:return not claude_auth_dead(current_fingerprint=credential_fingerprint(key))+def reachable_worker_families() -> list[str]:+ """Which worker families could run a heavy mission RIGHT NOW (cheap,+ offline — file reads + process-local flags, never a network probe).++ Same subscription-first order as ``_cross_family_last_resort_worker``:+ Claude Max CLI (auth-viable), codex ChatGPT OAuth, then the API-key+ families. Feeds the Sub-Agents section health so the app can warn+ BEFORE a mission is dispatched (2026-07-06: the tab stayed green for+ 17 hours of guaranteed-dead spawns).+ """+ families: list[str] = []+ from jarvis.missions.workers.claude_direct_worker import _resolve_claude_binary++ if _resolve_claude_binary() is not None and _claude_cli_auth_viable():+ families.append("claude")+ from jarvis.codex_auth_state import codex_needs_reauth+ from jarvis.missions.workers.codex_direct_worker import _codex_oauth_available++ if _codex_oauth_available() and not codex_needs_reauth():+ families.append("codex")+ from jarvis.core.config import get_provider_secret+ from jarvis.missions.workers.api_agent_worker import supports_api_agent_worker++ for prov in ("claude-api", "gemini", "openrouter", "openai"):+ if supports_api_agent_worker(prov) and get_provider_secret(prov):+ families.append(prov)+ return families++def _cross_family_last_resort_worker(task_text: str) -> Any | None:"""The key-aware, cross-family LAST-resort heavy worker (open-source AP-22/23).diff --git a/jarvis/ui/web/provider_routes.py b/jarvis/ui/web/provider_routes.pyindex f9ae973080..8197cece8c 100644--- a/jarvis/ui/web/provider_routes.py+++ b/jarvis/ui/web/provider_routes.py@@ -673,12 +673,36 @@ def _worker_usable(provider: str) -> bool:return False+def _worker_flagged_dead(provider: str) -> bool:+ """True when the SELECTED worker provider is proven dead/cooling right+ now — signals the presence-only ``_worker_usable`` cannot see (the+ 2026-07-06 gap: an expired-in-place OAuth token, a session-dead flag, a+ quota cooldown). Cheap + offline; any probe failure degrades to False+ (fall back to the presence check, never a false red).+ """+ p = (provider or "").lower()+ try:+ if p in {"claude-api", "claude"}:+ from jarvis.claude_quota_state import claude_in_quota_cooldown+ from jarvis.missions.init import _claude_cli_auth_viable++ return claude_in_quota_cooldown() or not _claude_cli_auth_viable()+ if p in _CODEX_SUBAGENT_SLUGS or p in {"codex", "openai-codex"}:+ from jarvis.codex_auth_state import codex_needs_reauth++ return codex_needs_reauth()+ except Exception: # noqa: BLE001+ return False+ return False++def _jarvis_agent_section_health(cfg: Any) -> SectionHealth:"""Subagents tab: reflects whether the SELECTED heavy-task worker is usable.A real "does it answer" call for a CLI worker is heavy, so v1 reports the- connectedness signal — connected/keyed → ok, otherwise needs_setup. It never- flags ``error`` (a connected-but-failing CLI worker is out of scope here).+ connectedness signal — connected/keyed → ok, otherwise needs_setup. Since+ 2026-07-07 it distinguishes degraded (fallback carries) from error+ (nothing reachable)."""brain = getattr(cfg, "brain", None) if cfg is not None else Noneif brain is None:@@ -699,14 +723,35 @@ def _jarvis_agent_section_health(cfg: Any) -> SectionHealth:)spec = get_spec(provider)label = spec.label if spec is not None else provider- if _worker_usable(provider):+ if _worker_usable(provider) and not _worker_flagged_dead(provider):return SectionHealth(status=_section_health.OK, reason="ok", detail=f"Subagent worker: {label}")+ # The selected worker cannot run right now. Distinguish "a fallback+ # family carries the missions" (amber) from "nothing is reachable —+ # the next mission WILL fail" (red).+ try:+ from jarvis.missions.init import reachable_worker_families++ families = reachable_worker_families()+ except Exception: # noqa: BLE001+ families = []+ if families:+ return SectionHealth(+ status=_section_health.NEEDS_SETUP,+ reason="degraded",+ detail=(+ f"Subagent worker '{label}' is unavailable — missions run on "+ f"{families[0]} until it is reconnected"+ ),+ )return SectionHealth(- status=_section_health.NEEDS_SETUP,- reason="not_configured",- detail=f"Subagent worker '{label}' is not connected",+ status=_section_health.ERROR,+ reason="no_provider",+ detail=(+ f"No subagent provider is reachable — missions will fail. "+ f"Reconnect '{label}' or add an API key."+ ),)diff --git a/tests/missions/test_reachable_worker_families.py b/tests/missions/test_reachable_worker_families.pynew file mode 100644index 0000000000..62f806bc02--- /dev/null+++ b/tests/missions/test_reachable_worker_families.py@@ -0,0 +1,64 @@+"""reachable_worker_families() — the cheap, offline family probe that feeds+the Sub-Agents section health (which families could run a mission RIGHT NOW).+Same probe seams as tests/missions/test_worker_cross_family_fallback.py."""+from __future__ import annotations++import pytest++from jarvis.missions import init as mi+++def _patch_env(+ monkeypatch: pytest.MonkeyPatch,+ *,+ claude_binary: str | None = None,+ claude_auth_viable: bool = True,+ codex_oauth: bool = False,+ codex_reauth: bool = False,+ keys: tuple[str, ...] = (),+) -> None:+ monkeypatch.setattr(+ "jarvis.missions.workers.claude_direct_worker._resolve_claude_binary",+ lambda: claude_binary,+ )+ monkeypatch.setattr(mi, "_claude_cli_auth_viable", lambda: claude_auth_viable)+ monkeypatch.setattr(+ "jarvis.missions.workers.codex_direct_worker._codex_oauth_available",+ lambda: codex_oauth,+ )+ monkeypatch.setattr(+ "jarvis.codex_auth_state.codex_needs_reauth", lambda: codex_reauth+ )+ keyset = {k.strip().lower() for k in keys}+ monkeypatch.setattr(+ "jarvis.core.config.get_provider_secret",+ lambda p: "KEY" if (p or "").strip().lower() in keyset else None,+ )+++def test_all_dead_returns_empty(monkeypatch: pytest.MonkeyPatch) -> None:+ _patch_env(monkeypatch)+ assert mi.reachable_worker_families() == []+++def test_subscription_first_ordering(monkeypatch: pytest.MonkeyPatch) -> None:+ _patch_env(+ monkeypatch,+ claude_binary="/usr/bin/claude", claude_auth_viable=True,+ codex_oauth=True, keys=("openrouter",),+ )+ fams = mi.reachable_worker_families()+ assert fams[0] == "claude"+ assert "codex" in fams and "openrouter" in fams+++def test_dead_claude_is_not_listed(monkeypatch: pytest.MonkeyPatch) -> None:+ """The 2026-07-06 shape: binary present, auth dead -> claude absent."""+ _patch_env(+ monkeypatch,+ claude_binary="/usr/bin/claude", claude_auth_viable=False,+ codex_oauth=True,+ )+ fams = mi.reachable_worker_families()+ assert "claude" not in fams+ assert fams == ["codex"]diff --git a/tests/unit/brain/test_section_health.py b/tests/unit/brain/test_section_health.pyindex d6bbf95e3f..76a782a219 100644--- a/tests/unit/brain/test_section_health.py+++ b/tests/unit/brain/test_section_health.py@@ -70,3 +70,57 @@ class TestAggregate:def test_vocabulary_is_exactly_four() -> None:assert set(sh.SECTION_HEALTH_STATUSES) == {sh.OK, sh.NEEDS_SETUP, sh.ERROR, sh.UNKNOWN}assert len(sh.SECTION_HEALTH_STATUSES) == 4+++class TestSubagentSectionHealth:+ """Live-honest Sub-Agents tab health (2026-07-06 incident: the tab stayed+ green while every worker spawn 401'd on an expired OAuth token)."""++ def _cfg(self, provider: str = "claude-api"):+ class _Sub: # minimal cfg.brain.worker stand-in+ pass++ sub = _Sub()+ sub.provider = provider++ class _Brain:+ worker = sub+ primary = "openrouter"++ class _Cfg:+ brain = _Brain()++ return _Cfg()++ def test_selected_usable_is_ok(self, monkeypatch) -> None:+ from jarvis.ui.web import provider_routes as pr++ monkeypatch.setattr(pr, "_worker_usable", lambda p: True)+ monkeypatch.setattr(pr, "_worker_flagged_dead", lambda p: False)+ health = pr._jarvis_agent_section_health(self._cfg())+ assert health.status == sh.OK++ def test_selected_dead_with_fallback_is_needs_setup(self, monkeypatch) -> None:+ from jarvis.ui.web import provider_routes as pr++ monkeypatch.setattr(pr, "_worker_usable", lambda p: True)+ monkeypatch.setattr(pr, "_worker_flagged_dead", lambda p: True)+ monkeypatch.setattr(+ "jarvis.missions.init.reachable_worker_families", lambda: ["codex"]+ )+ health = pr._jarvis_agent_section_health(self._cfg())+ assert health.status == sh.NEEDS_SETUP+ assert health.reason == "degraded"+ assert "codex" in health.detail++ def test_nothing_reachable_is_error(self, monkeypatch) -> None:+ from jarvis.ui.web import provider_routes as pr++ monkeypatch.setattr(pr, "_worker_usable", lambda p: False)+ monkeypatch.setattr(pr, "_worker_flagged_dead", lambda p: False)+ monkeypatch.setattr(+ "jarvis.missions.init.reachable_worker_families", lambda: []+ )+ health = pr._jarvis_agent_section_health(self._cfg())+ assert health.status == sh.ERROR+ assert health.reason == "no_provider"