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
perf(realtime): pay the subscription cold start before the call, not inside it
Ruben Lütke2604cb397c45
diff --git a/jarvis/plugins/realtime/codex_subscription.py b/jarvis/plugins/realtime/codex_subscription.pyindex 7b67b7bf65..d2d0afdcee 100644--- a/jarvis/plugins/realtime/codex_subscription.py+++ b/jarvis/plugins/realtime/codex_subscription.py@@ -1060,6 +1060,27 @@ class CodexSubscriptionRealtimeProvider:await client.close()raise+ @classmethod+ async def warm_transport(cls, cfg: Any) -> None:+ """Pay the app-server cold start BEFORE a call, never inside one.++ Measured 2026-08-02: the process spawn plus live account verification+ happened inside the handshake and cost ~1.5 s of its 3.0 s. Until now+ the only warm path was the UI's provider-selection route, so a user+ who simply says the wake word pays it every time the app restarts.++ Best-effort by contract: a failure here changes nothing except that+ the next call pays what it pays today, so it must never propagate.+ """+ try:+ await cls.verify_activation(cfg)+ except Exception: # noqa: BLE001 - warming is advisory, never fatal+ log.warning(+ "Codex subscription realtime could not warm its transport; "+ "the first call will pay the cold start",+ exc_info=True,+ )+def __init__(self,*,diff --git a/jarvis/realtime/factory.py b/jarvis/realtime/factory.pyindex eda3ae4991..3d55bff688 100644--- a/jarvis/realtime/factory.py+++ b/jarvis/realtime/factory.py@@ -176,6 +176,31 @@ def realtime_requires_webrtc_offer(cfg: Any) -> bool:return False+async def realtime_warm_selected_transports(cfg: Any) -> None:+ """Let every explicitly selected provider pre-open its transport.++ A capability probe, never a provider-id check (AP-21): a provider that+ declares no ``warm_transport`` is simply skipped. Only explicitly selected+ primary/fallback providers are warmed — an installed-but-unselected plugin+ must not spawn a process or touch a credential on its own.++ Warming exists because the Codex subscription adapter otherwise spawns its+ app-server and verifies the account INSIDE the first call's handshake+ (~1.5 s of 3.0 s, measured 2026-08-02). One broken plugin never stops the+ others, and no failure here reaches the caller.+ """+ for provider_id in _explicit_provider_ids(cfg):+ try:+ provider_cls = load(_GROUP, provider_id, protocol=RealtimeProvider)+ warm = getattr(provider_cls, "warm_transport", None)+ if callable(warm):+ await warm(cfg)+ except Exception as exc: # noqa: BLE001 - one broken plugin is skipped+ log.warning(+ "Realtime transport warm failed for %s: %s", provider_id, exc+ )++def _provider_family(provider_id: str) -> str:"""Credential/quota family of a provider id (AP-22 diagnostics only)."""pid = (provider_id or "").strip().lower()diff --git a/jarvis/ui/desktop_app.py b/jarvis/ui/desktop_app.pyindex 43ed7eebec..7abd20f73c 100644--- a/jarvis/ui/desktop_app.py+++ b/jarvis/ui/desktop_app.py@@ -63,6 +63,10 @@ META_FILE_PATH = DATA_DIR / ".jarvis-running"#: so we detect a running process immediately and focus it instead of#: waiting silently._LOCK_ACQUIRE_TIMEOUT = 0.0+#: Delay before the selected realtime transport is pre-opened in the+#: background. Long enough to stay out of the brain/MCP build's CPU and disk+#: window, far shorter than a user reaching for the wake word.+_REALTIME_WARM_DELAY_S = 5.0def _local_voice_permission_granted(@@ -2062,6 +2066,37 @@ class DesktopApp:loop.create_task(_provision_wake_model(), name="wake-model-provision")+ async def _warm_realtime_transport() -> None:+ """Pre-open the selected realtime transport, off the boot path.++ Same slot and the same reasoning as the wake-model provision+ above: created AFTER the app-interactive mark and after the+ server start, so neither boot-budget mark can move (AP-26).+ The extra delay keeps a process spawn and a network account+ check out of the brain/MCP build's CPU and disk window.++ Without it, the Codex subscription adapter spawns its+ app-server and verifies the account inside the first call's+ handshake — measured 2026-08-02 at ~1.5 s of 3.0 s.+ """+ try:+ await asyncio.sleep(_REALTIME_WARM_DELAY_S)+ from jarvis.core.config import load_config+ from jarvis.realtime.factory import (+ realtime_warm_selected_transports,+ )++ await realtime_warm_selected_transports(load_config())+ except Exception: # noqa: BLE001 — warming never crashes boot+ from loguru import logger as _warm_log+ _warm_log.opt(exception=True).debug(+ "Off-boot realtime transport warm skipped."+ )++ loop.create_task(+ _warm_realtime_transport(), name="realtime-transport-warm"+ )+loop.create_task(_heavy_backend_bg(), name="heavy-backend")loop.call_soon(self._start_virtual_cursor)# Watch this loop from OFF it, for the rest of the process's life.diff --git a/tests/unit/realtime/test_codex_subscription.py b/tests/unit/realtime/test_codex_subscription.pyindex 661fa1935d..e0334fc287 100644--- a/tests/unit/realtime/test_codex_subscription.py+++ b/tests/unit/realtime/test_codex_subscription.py@@ -1456,3 +1456,22 @@ async def test_the_negotiated_protocol_and_voice_are_logged(caplog) -> None:for record in caplog.records)await session.close()+++async def test_warm_transport_never_raises(monkeypatch) -> None:+ """The whole point is to move a cold start OUT of the call. A warm that+ fails may only mean the next call pays what it pays today."""+ calls = []++ async def _boom(cfg): # noqa: ANN001 - classmethod shape+ calls.append(cfg)+ raise RuntimeError("no login")++ monkeypatch.setattr(+ CodexSubscriptionRealtimeProvider, "verify_activation", _boom+ )++ await CodexSubscriptionRealtimeProvider.warm_transport(object())++ assert len(calls) == 1diff --git a/tests/unit/realtime/test_factory.py b/tests/unit/realtime/test_factory.pyindex 7a49a58dbc..8260206078 100644--- a/tests/unit/realtime/test_factory.py+++ b/tests/unit/realtime/test_factory.py@@ -6,6 +6,7 @@ from types import SimpleNamespaceimport pytest+import jarvis.realtime.factory as factoryfrom jarvis.core.config import VoiceConfigfrom jarvis.realtime.factory import (_provider_candidates,@@ -301,3 +302,79 @@ def test_cross_family_delegate_chain_stays_quiet(caplog):with caplog.at_level(logging.WARNING, logger="jarvis.realtime.factory"):_warn_on_same_family_delegate_chain(cfg, "gemini-live")assert not [record for record in caplog.records if "AP-22" in record.message]+++class _WarmProbe:+ """Minimal realtime provider exposing the optional warm capability."""++ supports_realtime = True++ def __init__(self) -> None:+ self.calls = 0++ async def warm_transport(self, cfg) -> None: # noqa: ANN001 - probe shape+ del cfg+ self.calls += 1+++class _NoWarmProbe:+ supports_realtime = True+++async def test_warm_selected_transports_skips_providers_without_the_capability(+ monkeypatch,+) -> None:+ """A capability probe, never a provider-id check (AP-21)."""+ warm = _WarmProbe()+ loaded = {"warm-me": warm, "plain": _NoWarmProbe()}+ monkeypatch.setattr(+ factory, "_explicit_provider_ids", lambda _cfg: ["plain", "warm-me"]+ )+ monkeypatch.setattr(+ factory, "load", lambda _group, pid, protocol=None: loaded[pid]+ )++ await factory.realtime_warm_selected_transports(object())++ assert warm.calls == 1+++async def test_warm_selected_transports_survives_one_broken_provider(+ monkeypatch,+) -> None:+ """Warming is advisory: a plugin that explodes must not stop the others,+ and must never reach the caller."""+ warm = _WarmProbe()++ def _load(_group, pid, protocol=None): # noqa: ANN001 - probe shape+ if pid == "broken":+ raise RuntimeError("plugin exploded")+ return warm++ monkeypatch.setattr(+ factory, "_explicit_provider_ids", lambda _cfg: ["broken", "warm-me"]+ )+ monkeypatch.setattr(factory, "load", _load)++ await factory.realtime_warm_selected_transports(object())++ assert warm.calls == 1+++async def test_warm_selected_transports_ignores_unselected_plugins(+ monkeypatch,+) -> None:+ """An installed but unselected plugin must not spawn a process or touch a+ credential on its own."""+ warm = _WarmProbe()+ monkeypatch.setattr(factory, "_explicit_provider_ids", lambda _cfg: [])+ monkeypatch.setattr(+ factory, "load", lambda _group, _pid, protocol=None: warm+ )++ await factory.realtime_warm_selected_transports(object())++ assert warm.calls == 0