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(tasks): stop automatic speech output on agent routine completion (RUB-95)

rubenluetke10-beep1e47ae70b792
diff --git a/jarvis/tasks/runner.py b/jarvis/tasks/runner.py
index f70c7c0a48..32c4c27d86 100644
--- a/jarvis/tasks/runner.py
+++ b/jarvis/tasks/runner.py
@@ -615,19 +615,11 @@ class TaskRunner:
await self._result_sink(tags, text, "done")
except Exception: # noqa: BLE001 — the task succeeded; a failed delivery is logged
log.warning("task %s: result sink failed for tags %s", task_id, tags, exc_info=True)
- # Delivery: speak the result at the next VAD turn-boundary. The TTS
- # pipeline scrubs it; on a muted/headless runtime this is a logged
- # no-op (cloud-first). The result also stays visible as the step above
- # in the task's detail timeline.
- if text:
- await self._bus.publish(
- AnnouncementRequested(
- text=text,
- # A scheduled/background task result is sub-agent output.
- kind="subagent",
- source_layer="tasks.runner",
- )
- )
+ # RUB-95: an agent routine completing must never trigger automatic
+ # speech output. The result stays visible as the agent_result step
+ # above (and via result_sink in the owner's chat); spoken output is
+ # reserved for an explicit opt-in via announce_on_success/failure
+ # (handled in run() -> _announce) or an explicit SpeakAction.
async def _run_tool_call(
self,
diff --git a/jarvis/tasks/schema.py b/jarvis/tasks/schema.py
index d60933b0f5..53e346bf2e 100644
--- a/jarvis/tasks/schema.py
+++ b/jarvis/tasks/schema.py
@@ -378,8 +378,8 @@ class TaskSpec(BaseModel):
created_by: str = "user" # "user" | "skill" | "brain"
tags: tuple[str, ...] = Field(default_factory=tuple)
# When-Then notify: a spoken confirmation emitted after the action's
- # terminal outcome, action-agnostic (the `harness_dispatch`/CU path does not
- # self-announce, unlike `agent`). Published as AnnouncementRequested(
+ # terminal outcome, action-agnostic (no action self-announces; RUB-95).
+ # Published as AnnouncementRequested(
# kind="subagent"), which punches through the voice hangup gate and is
# mirrored to browser tabs — so "let me know" works post-hangup and headless.
# Both support {field} placeholders interpolated from the triggering event
diff --git a/tests/unit/tasks/test_runner_agent_result.py b/tests/unit/tasks/test_runner_agent_result.py
index 0c797f3b19..3427a2e045 100644
--- a/tests/unit/tasks/test_runner_agent_result.py
+++ b/tests/unit/tasks/test_runner_agent_result.py
@@ -12,6 +12,7 @@ import pytest
from jarvis.control.cancel import CancelToken
from jarvis.core.bus import EventBus
+from jarvis.core.events import AnnouncementRequested, TaskCompleted
from jarvis.tasks.runner import TaskRunner
from jarvis.tasks.schema import AgentAction, TaskSpec, TriggerAfterDelay
from jarvis.tasks.store import TaskStore
@@ -98,3 +99,109 @@ async def test_a_failing_sink_never_fails_the_task(store: TaskStore, caplog) ->
row = await store.get(task_id)
assert row is not None and row["state"] == "completed"
assert any("result sink failed" in r.getMessage() for r in caplog.records)
+
+
+def _collect(bus: EventBus, event_type: type) -> list:
+ got: list = []
+
+ async def _on(event) -> None:
+ got.append(event)
+
+ bus.subscribe(event_type, _on)
+ return got
+
+
+async def test_rub95_agent_routine_completion_requests_no_automatic_speech(
+ store: TaskStore,
+) -> None:
+ """RUB-95: routine completion -> result processing -> no automatic speech.
+
+ The agent result must stay visible (result sink + agent_result step +
+ TaskCompleted) while no AnnouncementRequested is emitted, with or without
+ an active voice session (no request means nothing can start speaking).
+ """
+ delivered: list[tuple[tuple[str, ...], str, str]] = []
+
+ async def sink(tags: tuple[str, ...], text: str, status: str) -> None:
+ delivered.append((tags, text, status))
+
+ bus = EventBus()
+ announcements = _collect(bus, AnnouncementRequested)
+ completions = _collect(bus, TaskCompleted)
+ runner = TaskRunner(store, bus, agent_brain=FakeAgentBrain(), result_sink=sink)
+ spec = TaskSpec(
+ title="[agent:Mailbox] Inbox sweep",
+ trigger=TriggerAfterDelay(delay_seconds=0.01),
+ action=AgentAction(prompt="Sort the inbox."),
+ tags=("society", "agent:mailbox"),
+ )
+ task_id = await store.insert(spec)
+ await asyncio.wait_for(runner.run(task_id, CancelToken()), timeout=2.0)
+
+ assert announcements == []
+ assert delivered == [(("society", "agent:mailbox"), "Inbox sorted: 3 replies drafted.", "done")]
+ assert len(completions) == 1 and completions[0].task_id == task_id
+ row = await store.get(task_id)
+ assert row is not None and row["state"] == "completed"
+ agent_steps = [
+ s
+ for s in row["steps"]
+ if s["kind"] == "log" and s["payload"].get("event") == "agent_result"
+ ]
+ assert len(agent_steps) == 1
+ assert "Inbox sorted" in agent_steps[0]["payload"]["text"]
+
+
+async def test_rub95_owned_society_routine_completion_stays_silent(
+ store: TaskStore,
+) -> None:
+ """RUB-95 owned path: run_owned_routine answer must not trigger speech."""
+
+ async def owned_runner(task_id: str, tags: tuple[str, ...], prompt: str, cancel: Any):
+ assert tags == ("society", "agent:mailbox")
+ return "Routine answer from the owner's chat."
+
+ bus = EventBus()
+ announcements = _collect(bus, AnnouncementRequested)
+ runner = TaskRunner(store, bus, owned_agent_runner=owned_runner)
+ spec = TaskSpec(
+ title="[agent:Mailbox] Owned sweep",
+ trigger=TriggerAfterDelay(delay_seconds=0.01),
+ action=AgentAction(prompt="Sort the inbox."),
+ tags=("society", "agent:mailbox"),
+ )
+ task_id = await store.insert(spec)
+ await asyncio.wait_for(runner.run(task_id, CancelToken()), timeout=2.0)
+
+ assert announcements == []
+ row = await store.get(task_id)
+ assert row is not None and row["state"] == "completed"
+ agent_steps = [
+ s
+ for s in row["steps"]
+ if s["kind"] == "log" and s["payload"].get("event") == "agent_result"
+ ]
+ assert len(agent_steps) == 1
+ assert "Routine answer" in agent_steps[0]["payload"]["text"]
+
+
+async def test_rub95_explicit_announce_on_success_still_speaks_once(
+ store: TaskStore,
+) -> None:
+ """Explicit opt-in read-aloud keeps working — exactly once, templated."""
+ bus = EventBus()
+ announcements = _collect(bus, AnnouncementRequested)
+ runner = TaskRunner(store, bus, agent_brain=FakeAgentBrain())
+ spec = TaskSpec(
+ title="[agent:Mailbox] Inbox sweep",
+ trigger=TriggerAfterDelay(delay_seconds=0.01),
+ action=AgentAction(prompt="Sort the inbox."),
+ tags=("society", "agent:mailbox"),
+ announce_on_success="Inbox sweep done.",
+ )
+ task_id = await store.insert(spec)
+ await asyncio.wait_for(runner.run(task_id, CancelToken()), timeout=2.0)
+
+ assert len(announcements) == 1
+ assert announcements[0].text == "Inbox sweep done."
+ assert announcements[0].kind == "subagent"