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(voice): report finished work to a live call on an install without a speech pipeline (#697)

Ruben Lütkef9b7920b023b
diff --git a/jarvis/live/announcements.py b/jarvis/live/announcements.py
new file mode 100644
index 0000000000..28d969ebc5
--- /dev/null
+++ b/jarvis/live/announcements.py
@@ -0,0 +1,83 @@
+"""Owed results for a live call on an install without a speech pipeline.
+
+A finished agent, a watched pane or a late answer is published as an
+``AnnouncementRequested``. On the desktop the speech pipeline hands it to the
+live call. A headless or browser-only install has no speech pipeline, so the
+result had nowhere to go and the call never heard it. This bridge delivers
+it there, and stays out of the way wherever a speech pipeline runs.
+"""
+
+from __future__ import annotations
+
+import asyncio
+import logging
+from typing import Any, Final
+
+from jarvis.core.events import AnnouncementRequested
+
+log = logging.getLogger(__name__)
+
+#: Kinds that carry an outcome the user is owed. Preambles and progress lines
+#: belong to a turn the live model is speaking itself.
+_OWED_KINDS: Final[frozenset[str]] = frozenset({"completion", "subagent"})
+#: A call refuses a report while a turn is in flight; it is offered again at
+#: this pace until the call takes it or ends.
+RETRY_S: Final[float] = 2.0
+ATTEMPTS: Final[int] = 90
+
+_pending: set[asyncio.Task] = set()
+
+
+def _owed(event: AnnouncementRequested) -> bool:
+ return event.kind in _OWED_KINDS or bool(str(event.report or "").strip())
+
+
+def _live_call() -> Any | None:
+ from jarvis.live.runtime import active
+
+ return next((s for s in active() if getattr(s, "is_active", False)), None)
+
+
+async def deliver_to_live_call(event: AnnouncementRequested) -> None:
+ """Bus subscriber: hand an owed result to the live call when nothing else will."""
+ from jarvis.core.runtime_refs import get_speech_pipeline
+
+ if get_speech_pipeline() is not None or not _owed(event) or _live_call() is None:
+ return
+ task = asyncio.create_task(_hand_over(event), name="live-call-result")
+ _pending.add(task)
+ task.add_done_callback(_pending.discard)
+
+
+async def _hand_over(event: AnnouncementRequested) -> bool:
+ from jarvis.brain.output_filter import scrub_for_voice
+ from jarvis.live.runtime import on_session_loop
+
+ language = str(event.language or "")
+ text = scrub_for_voice(str(event.text or ""), language=language).cleaned
+ report = str(event.report or "").strip()
+ extra: dict[str, Any] = {"report": report} if report else {}
+ for _ in range(ATTEMPTS):
+ session = _live_call()
+ if session is None:
+ return False
+
+ async def offer(target: Any = session) -> bool:
+ return bool(await target.deliver_announcement(
+ text=text, language=language, spoken_kind=event.kind or "announcement",
+ detail=event.detail, **extra,
+ ))
+
+ try:
+ if await on_session_loop(session, offer):
+ return True
+ except RuntimeError: # the call ended or changed meanwhile: look again
+ log.debug("live-call result: the call changed before delivery")
+ except Exception: # noqa: BLE001 - a failed handoff must not end the retries
+ log.warning("live-call result: delivery failed", exc_info=True)
+ await asyncio.sleep(RETRY_S)
+ log.warning("live-call result: the call never took %r", text[:80])
+ return False
+
+
+__all__ = ["ATTEMPTS", "RETRY_S", "deliver_to_live_call"]
diff --git a/jarvis/ui/web/server.py b/jarvis/ui/web/server.py
index 78cbe2d664..17ed829546 100644
--- a/jarvis/ui/web/server.py
+++ b/jarvis/ui/web/server.py
@@ -247,6 +247,11 @@ class WebServer:
# unchanged. See docs/superpowers/specs/2026-05-11-pre-thinking-ack-
# flash-brain-design.md §4.
self.bus.subscribe(AnnouncementRequested, self._forward_preamble_to_chat)
+ # An owed result reaches a live call through the speech pipeline; an
+ # install without one (headless, browser voice only) hands it over here.
+ from jarvis.live.announcements import deliver_to_live_call
+
+ self.bus.subscribe(AnnouncementRequested, deliver_to_live_call)
from jarvis.core import runtime_refs
from jarvis.missions.tool_approvals import (
MissionToolApprovalCoordinator,
diff --git a/tests/unit/live/test_announcements_without_pipeline.py b/tests/unit/live/test_announcements_without_pipeline.py
new file mode 100644
index 0000000000..1e095a6798
--- /dev/null
+++ b/tests/unit/live/test_announcements_without_pipeline.py
@@ -0,0 +1,110 @@
+"""An owed result reaches a live call on an install without a speech pipeline."""
+
+from __future__ import annotations
+
+import asyncio
+from uuid import uuid4
+
+import pytest
+
+from jarvis.core import runtime_refs
+from jarvis.core.events import AnnouncementRequested
+from jarvis.live import announcements, runtime
+
+
+class _Call:
+ """A live call that takes a report after refusing the first ``busy`` offers."""
+
+ def __init__(self, *, busy: int = 0) -> None:
+ self.session_id = "call-1"
+ self.is_active = True
+ self.busy = busy
+ self.offers: list[dict] = []
+
+ async def deliver_announcement(self, **kwargs) -> bool:
+ self.offers.append(kwargs)
+ if self.busy:
+ self.busy -= 1
+ return False
+ return True
+
+
+def _result(**overrides) -> AnnouncementRequested:
+ fields = {
+ "trace_id": uuid4(), "source_layer": "agentic_ide.readback", "kind": "completion",
+ "language": "en", "text": "T1 has finished: **done**", "report": "done",
+ }
+ return AnnouncementRequested(**{**fields, **overrides})
+
+
+def no_pipeline(monkeypatch):
+ monkeypatch.setattr(runtime, "_active", {})
+ monkeypatch.setattr(runtime, "_owners", {})
+ monkeypatch.setattr(runtime_refs, "_SPEECH_PIPELINE", [])
+ monkeypatch.setattr(announcements, "RETRY_S", 0.01)
+
+
+async def _settle() -> None:
+ for _ in range(50):
+ if not announcements._pending:
+ return
+ await asyncio.sleep(0.01)
+
+
+async def test_a_finished_agent_is_reported_to_the_call(no_pipeline):
+ call = _Call()
+ runtime.register(call)
+ await announcements.deliver_to_live_call(_result())
+ await _settle()
+ assert len(call.offers) == 1
+ offer = call.offers[0]
+ assert offer["report"] == "done" and offer["spoken_kind"] == "completion"
+ assert "**" not in offer["text"] and offer["language"] == "en"
+
+
+async def test_a_busy_call_is_offered_the_report_again(no_pipeline):
+ call = _Call(busy=2)
+ runtime.register(call)
+ await announcements.deliver_to_live_call(_result())
+ await _settle()
+ assert len(call.offers) == 3 # refused twice while a turn ran, then taken
+
+
+async def test_the_speech_pipeline_keeps_the_delivery_where_it_runs(no_pipeline, monkeypatch):
+ call = _Call()
+ runtime.register(call)
+ monkeypatch.setattr(runtime_refs, "_SPEECH_PIPELINE", [object()])
+ await announcements.deliver_to_live_call(_result())
+ await _settle()
+ assert call.offers == []
+
+
+async def test_a_line_spoken_inside_a_turn_is_not_handed_over(no_pipeline):
+ call = _Call()
+ runtime.register(call)
+ await announcements.deliver_to_live_call(_result(kind="preamble", report=None))
+ await announcements.deliver_to_live_call(_result(kind="progress", report=None))
+ await _settle()
+ assert call.offers == []
+ # An info line carrying an agent's report is still owed.
+ await announcements.deliver_to_live_call(_result(kind="info", report="three mails"))
+ await _settle()
+ assert len(call.offers) == 1
+
+
+async def test_nothing_is_kept_waiting_without_a_call(no_pipeline):
+ await announcements.deliver_to_live_call(_result())
+ assert not announcements._pending
+
+
+async def test_a_call_that_ends_stops_the_offers(no_pipeline, monkeypatch):
+ monkeypatch.setattr(announcements, "ATTEMPTS", 500)
+ call = _Call(busy=10_000)
+ runtime.register(call)
+ await announcements.deliver_to_live_call(_result())
+ await asyncio.sleep(0.05)
+ runtime.unregister(call.session_id)
+ await _settle()
+ assert not announcements._pending
+ assert 0 < len(call.offers) < 500