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(voice): never speak background news without an open call
rubenluetke10-beep9cf97e246960
diff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.pyindex 8fca8f90d3..ebe8d72ea6 100644--- a/jarvis/speech/pipeline.py+++ b/jarvis/speech/pipeline.py@@ -389,6 +389,20 @@ _READBACK_KINDS: frozenset[str] = frozenset()+#: Readback sources that never speak outside a call (see ``_is_agent_reply``).+#: A mission the user just asked for is not here: its answer may still punch+#: through the hangup gate (AD-OE5/OE6).+_HELD_FOR_CALL_SOURCES: frozenset[str] = frozenset(+ {+ "society.lead",+ "tasks.runner",+ "workflows.runner",+ "workflows.scheduler",+ "desktop_app.conductor",+ }+)++def _announcement_spoken_kind(kind: str | None) -> str:"""Map an ``AnnouncementRequested.kind`` to a ``SpeechSpoken.spoken_kind``.@@ -4823,7 +4837,15 @@ class SpeechPipeline:@staticmethoddef _is_agent_reply(event: AnnouncementRequested) -> bool:- return event.source_layer == "society.lead" and event.kind in _READBACK_KINDS+ """A readback that is owed to the user but must wait for an open call.++ An agent's reply, and every piece of background news nobody asked for+ in this conversation (a routine or automation result, a scheduled job+ failing or recovering). Spoken into an idle machine it is Jarvis+ talking without having been called; held here, it is delivered at the+ next call, once, and only after the audio actually finished.+ """+ return event.source_layer in _HELD_FOR_CALL_SOURCES and event.kind in _READBACK_KINDSdef _agent_reply_needs_session(self) -> bool:hangup = getattr(self, "_hangup_event", None)diff --git a/jarvis/tasks/runner.py b/jarvis/tasks/runner.pyindex 00082b82ac..e350735293 100644--- a/jarvis/tasks/runner.py+++ b/jarvis/tasks/runner.py@@ -234,21 +234,23 @@ class TaskRunner:log.exception("Task %s failed after %dms", task_id, duration_ms)tags = tuple(str(tag) for tag in spec.tags)if self._result_sink is not None and tags:+ # The owner's chat gets a sentence; ``last_error`` keeps the+ # precise ``Type: message`` line for the Runs tab.+ notice = routine_failure_sentence(str(getattr(spec, "title", "") or ""), error_msg)try:- await self._result_sink(tags, error_msg, "failed")+ await self._result_sink(tags, notice, "failed")except Exception: # noqa: BLE001 — the run already failed; delivery is best effortlog.warning("task %s: failure sink failed for tags %s", task_id, tags, exc_info=True)fail_ctx = {**ctx, "error": error_msg}+ # Only an explicitly configured failure announcement speaks (and+ # the voice holds it until the user's next call). An agent+ # routine's failure goes to its own chat above, never to the voice+ # unasked (RUB-95; it used to be read aloud as "RuntimeError: …").template = getattr(spec, "announce_on_failure", None)if template:await self._announce(template, fail_ctx)- elif "society" in tags:- # The template path formats ``{…}``; an error text is not a- # template, so its braces are escaped before it goes through.- spoken = spoken_routine_failure(str(getattr(spec, "title", "") or ""), error_msg)- await self._announce(spoken.replace("{", "{{").replace("}", "}}"), fail_ctx)returnduration_ms = int((time.perf_counter() - start) * 1000)@@ -881,13 +883,12 @@ _AGENT_TITLE_TAG_RE = re.compile(r"^\s*\[agent:[^\]]*\]\s*")_ROUTINE_WRAPPER_RE = re.compile(r"^The routine chat failed:\s*", re.IGNORECASE)-def spoken_routine_failure(title: str, error: str) -> str:- """The sentence an agent routine's failure is announced with.+def routine_failure_sentence(title: str, error: str) -> str:+ """How a failed routine is reported to a person: which one, and why.``last_error`` keeps the precise ``Type: message`` line for the Runs tab;- read aloud (and turned into a conversation title) that line was- "RuntimeError: The routine chat failed: …". A person hears which routine- failed and why, without the exception class or the wrapper phrase.+ a reader of the agent's chat gets neither the exception class nor the+ "The routine chat failed:" wrapper."""reason = _EXCEPTION_PREFIX_RE.sub("", error.strip())reason = _ROUTINE_WRAPPER_RE.sub("", reason).strip().rstrip(".")diff --git a/tests/unit/speech/test_agent_reply_readbacks.py b/tests/unit/speech/test_agent_reply_readbacks.pyindex 7fec34ac87..a9b44ec12a 100644--- a/tests/unit/speech/test_agent_reply_readbacks.py+++ b/tests/unit/speech/test_agent_reply_readbacks.py@@ -205,3 +205,37 @@ async def test_real_desktop_callbacks_confirm_only_a_completed_readback(monkeypaassert getattr(pipe, "_agent_reply_retries", []) == ([] if ending in {"complete", "surface"} else [event])+++ "source", ["tasks.runner", "workflows.runner", "workflows.scheduler", "desktop_app.conductor"]+)+async def test_background_news_waits_for_a_call_instead_of_speaking_unasked(source):+ """A routine result, an automation, a scheduled job recovering: none of+ them may speak into an idle machine. They are held and delivered at the+ next call."""+ pipe, tts, player, realtime = _pipeline(accepted=True)+ event = AnnouncementRequested(+ source_layer=source,+ kind="subagent",+ language="en",+ text="The scheduled job X is working again.",+ )+ pipe._turn_state = TurnTakingState.IDLE+ await pipe._on_announcement(event)+ assert pipe._deferred_announcements == [event]+ assert not realtime.calls and not tts.calls and not player.plays+ await pipe._set_turn_state(TurnTakingState.LISTENING)+ await asyncio.sleep(0.02)+ assert len(realtime.calls) == 1+++async def test_a_mission_readback_still_punches_through_after_hangup():+ """What the user asked for in this conversation is not background news."""+ pipe, _, _, _ = _pipeline(accepted=True)+ event = AnnouncementRequested(+ source_layer="missions.voice", kind="completion", language="en", text="Done."+ )+ assert not pipe._is_agent_reply(event)diff --git a/tests/unit/tasks/test_runner_agent_result.py b/tests/unit/tasks/test_runner_agent_result.pyindex dd7f1b6e10..381231c1f5 100644--- a/tests/unit/tasks/test_runner_agent_result.py+++ b/tests/unit/tasks/test_runner_agent_result.py@@ -244,7 +244,9 @@ async def test_a_failed_owner_seat_is_never_rerouted_onto_api(store: TaskStore)assert brain.prompts == []assert row["last_error"] is not None and "not rerouted" in row["last_error"]assert delivered and delivered[0][2] == "failed"- assert announcements and "not rerouted" in announcements[0].text+ # The reason reaches the owner's chat; the voice stays quiet (RUB-95).+ assert "not rerouted" in delivered[0][1]+ assert announcements == []seat_step = next(sfor s in row["steps"]@@ -309,7 +311,9 @@ async def test_a_paused_owner_is_explained_not_impersonated(store: TaskStore) ->assert brain.prompts == []assert row["last_error"] is not None and "paused" in row["last_error"]assert delivered and delivered[0][2] == "failed"- assert announcements and "paused" in announcements[0].text+ # The reason reaches the owner's chat; the voice stays quiet (RUB-95).+ assert "paused" in delivered[0][1]+ assert announcements == []async def test_no_brain_after_seat_failure_says_there_was_no_other_path(@@ -338,13 +342,21 @@ class FailingAgentBrain(FakeAgentBrain):raise RuntimeError("The routine chat failed: Individual quota reached {see plan}")-async def test_a_failed_agent_routine_is_announced_as_a_sentence(store: TaskStore) -> None:- """Read aloud, the raw ``last_error`` was "RuntimeError: The routine chat- failed: …" — and it became a conversation title. The announcement names- the routine and the reason; the stored error keeps the precise line."""+async def test_a_failed_agent_routine_reports_to_its_chat_and_never_speaks(+ store: TaskStore,+) -> None:+ """A failed routine was read aloud as "RuntimeError: The routine chat+ failed: …" with no call open, and that line became a conversation title.+ It now reaches only the agent's chat, as a sentence; ``last_error`` keeps+ the precise line."""bus = EventBus()spoken = _collect(bus, AnnouncementRequested)- runner = TaskRunner(store, bus, agent_brain=FailingAgentBrain())+ delivered: list[tuple[tuple[str, ...], str, str]] = []++ async def sink(tags: tuple[str, ...], text: str, status: str) -> None:+ delivered.append((tags, text, status))++ runner = TaskRunner(store, bus, agent_brain=FailingAgentBrain(), result_sink=sink)spec = TaskSpec(title="[agent:Mailbox] Inbox sweep",trigger=TriggerAfterDelay(delay_seconds=0.01),@@ -353,8 +365,13 @@ async def test_a_failed_agent_routine_is_announced_as_a_sentence(store: TaskStor)task_id = await store.insert(spec)await asyncio.wait_for(runner.run(task_id, CancelToken()), timeout=2.0)- assert [e.text for e in spoken] == [- 'The routine "Inbox sweep" failed: Individual quota reached {see plan}.'+ assert spoken == []+ assert delivered == [+ (+ ("society", "agent:mailbox"),+ 'The routine "Inbox sweep" failed: Individual quota reached {see plan}.',+ "failed",+ )]row = await store.get(task_id)assert row is not None and row["last_error"].startswith("RuntimeError: ")