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(awareness): summarize episodes on a connected subscription first
rubenluetke10-beep3bd21daa4881
diff --git a/jarvis/brain/factory.py b/jarvis/brain/factory.pyindex 5463d7c188..6b9b750d5b 100644--- a/jarvis/brain/factory.py+++ b/jarvis/brain/factory.py@@ -20,6 +20,10 @@ from typing import Any, Literallog = logging.getLogger(__name__)+# Deadline for one awareness summary on a subscription CLI: a CLI turn spends+# seconds on process start before the model even answers.+_VERDICHTER_SUBSCRIPTION_TIMEOUT_S = 60.0+BrainCallback = Callable[[str], Awaitable[str]]# Router-tier: pure-dispatcher set (grown via documented ADR-0011 amendments;@@ -1053,7 +1057,21 @@ def _phase2_full_brain()v_registry = BrainProviderRegistry()- v_brain = v_registry.instantiate(v_provider, model=v_model)+ from jarvis.brain.resolver import SubscriptionFirstBrain++ # Episode summaries are background work: a connected+ # subscription writes them, the keyed brain above only when+ # none is signed in. A CLI turn takes seconds, so the call+ # deadline is widened to the subscription budget.+ v_brain = SubscriptionFirstBrain(+ config,+ v_registry.instantiate(v_provider, model=v_model),+ cli_timeout_s=_VERDICHTER_SUBSCRIPTION_TIMEOUT_S,+ )+ if v_cfg.timeout_s < _VERDICHTER_SUBSCRIPTION_TIMEOUT_S:+ v_cfg = v_cfg.model_copy(+ update={"timeout_s": _VERDICHTER_SUBSCRIPTION_TIMEOUT_S}+ )awareness_manager._verdichter = Verdichter( # noqa: SLF001brain=v_brain, config=v_cfg,)diff --git a/jarvis/brain/resolver.py b/jarvis/brain/resolver.pyindex ecb7c8425d..8c722e3a46 100644--- a/jarvis/brain/resolver.py+++ b/jarvis/brain/resolver.py@@ -571,6 +571,48 @@ def resolve_subscription_brain(# Internal — Chain-Building# ----------------------------------------------------------------------+class SubscriptionFirstBrain:+ """Background brain: a connected subscription first, the keyed brain otherwise.++ For background callers built at boot (awareness summaries). The login probe+ spawns CLIs, so it runs lazily on the first call, off the event loop, and+ is re-checked after :attr:`RECHECK_S` so a later sign-in or sign-out is+ honoured. A key is spent only while no subscription is connected, which+ keeps a single-key install working (AP-22) without billing the voice key+ for work nobody waits on (live 2026-09-29).+ """++ RECHECK_S = 600.0++ def __init__(+ self, config: JarvisConfig, fallback: Brain, *, cli_timeout_s: float | None = None+ ) -> None:+ self._config = config+ self._fallback = fallback+ self._cli_timeout_s = cli_timeout_s+ self._chosen: Any = None+ self._checked_at = float("-inf")+ self.name = getattr(fallback, "name", "")++ async def _pick(self) -> Any:+ import asyncio+ import time++ now = time.monotonic()+ if self._chosen is None or now - self._checked_at >= self.RECHECK_S:+ subscription = await asyncio.to_thread(+ resolve_subscription_brain, self._config, cli_timeout_s=self._cli_timeout_s+ )+ self._chosen = subscription if subscription is not None else self._fallback+ self._checked_at = now+ return self._chosen++ async def complete(self, req: Any) -> Any:+ brain = await self._pick()+ async for delta in brain.complete(req):+ yield delta++def _resolve_chain(config: JarvisConfig) -> list[tuple[str, str | None]]:"""Builds the ordered (provider, model) list for the fallback chain.diff --git a/tests/unit/brain/test_resolve_subscription_brain.py b/tests/unit/brain/test_resolve_subscription_brain.pyindex 44c6fc478d..3f405a387b 100644--- a/tests/unit/brain/test_resolve_subscription_brain.py+++ b/tests/unit/brain/test_resolve_subscription_brain.py@@ -202,3 +202,35 @@ def test_every_subscription_card_can_answer_the_connection_probe() -> None:assert callable(getattr(brain_cls, "subscription_connected", None)), f"{spec.id} has no subscription_connected probe"+++class _TextBrain:+ def __init__(self, text: str) -> None:+ self.text = text++ async def complete(self, _req: Any): # noqa: ANN201+ yield self.text+++async def _collect(brain: Any) -> list[str]:+ return [delta async for delta in brain.complete(object())]+++def test_background_brain_prefers_a_connected_subscription(monkeypatch) -> None:+ import asyncio++ monkeypatch.setattr(+ resolver, "resolve_subscription_brain", lambda cfg, **_kw: _TextBrain("subscription")+ )+ brain = resolver.SubscriptionFirstBrain(_cfg(), _TextBrain("paid-key"))++ assert asyncio.run(_collect(brain)) == ["subscription"]+++def test_background_brain_uses_the_key_without_a_subscription(monkeypatch) -> None:+ import asyncio++ monkeypatch.setattr(resolver, "resolve_subscription_brain", lambda cfg, **_kw: None)+ brain = resolver.SubscriptionFirstBrain(_cfg(), _TextBrain("paid-key"))++ assert asyncio.run(_collect(brain)) == ["paid-key"]