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 a raw tool-result dict in Computer-Use readbacks
Ruben Lütkefad26b4ac45b
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.pyindex 4fdf404d3e..b6db5129c3 100644--- a/jarvis/brain/manager.py+++ b/jarvis/brain/manager.py@@ -58,7 +58,11 @@ from jarvis.core.turn_language import (resolve_output_language,resolve_turn_language,)-from jarvis.voice.action_phrases import action_phrase, cu_failure_readback+from jarvis.voice.action_phrases import (+ action_phrase,+ cu_failure_readback,+ cu_success_readback,+)from jarvis.memory import CoreMemory, PersonStore, RecallStore, Soul, UserProfilefrom jarvis.memory.curator import Curatorfrom jarvis.safety.tool_executor import ToolExecutor@@ -3729,7 +3733,20 @@ class BrainManager:timeout=timeout_s + 1.0,)if result.success:- text = str(result.output or "").strip() or action_phrase("cu_done", lang)+ # FORWARD the verifier's on-screen observation (sitting in the+ # harness stdout) as the readback so an informational request+ # ("...and check which tabs I have open") is actually answered —+ # and NEVER ``str()`` the raw ``dispatch_to_harness`` result DICT+ # ({'harness': ..., 'exit_code': ..., 'stdout': ..., 'cost_usd':+ # ..., 'duration_ms': ...}), which used to leak verbatim into the+ # spoken/chat turn (live bug 2026-06-22, voice "geh in die+ # Einstellungen und öffne Bluetooth"; the scrubbed ``''`` key was+ # the blacklisted word "harness"). This is the SUCCESS sibling of+ # the ``cu_failure_readback`` humanization below and uses the same+ # static parse as the ``computer_use`` tool path — no LLM (AP-11).+ output = getattr(result, "output", None)+ stdout = output.get("stdout") if isinstance(output, dict) else None+ text = cu_success_readback(lang, stdout=stdout)else:err = getattr(result, "error", None)exit_code, detail = self._cu_failure_detail(diff --git a/jarvis/brain/output_filter.py b/jarvis/brain/output_filter.pyindex 879b171f92..aebd25096d 100644--- a/jarvis/brain/output_filter.py+++ b/jarvis/brain/output_filter.py@@ -73,6 +73,10 @@ OPENER_BUDGET = 60FALLBACK_PHRASES: dict[str, str] = {"de": "Es trat ein Fehler auf.","en": "An error occurred.",+ # Runtime-output-language doctrine: every spoken phrase table carries all+ # supported locales (de/en/es) so a Spanish-pinned user never falls back to+ # German. Used by the stacktrace, raw-dump, and post-scrub-residue guards.+ "es": "Se produjo un error.",}@@ -86,6 +90,25 @@ STACKTRACE_RE = re.compile(re.DOTALL,)+# Raw data-structure dump guard (live bug 2026-06-22). A code path may ``str()``+# a tool-result container (dict / list of dicts) instead of humanizing it — e.g.+# the whole ``dispatch_to_harness`` result ``{'harness': 'screenshot',+# 'exit_code': 0, 'stdout': …, 'cost_usd': …, 'duration_ms': …}`` reached a+# readback verbatim. The per-pattern tool-leak rules below only catch SPECIFIC+# named shapes ({"tool":…}, XML, YAML, prose) and SPECIFIC keys, so a new result+# shape or a single-quoted Python repr slips through. This is the STRUCTURAL,+# key-independent, quote-style-independent guard that makes the whole bug class+# impossible at the common chokepoint: if the text OPENS with a container ``{``/+# ``[`` and carries a mapping signature (a quoted ``key:`` or a ``key='…'``+# repr), it is a machine dump, never a spoken sentence — fail-closed to the+# standard phrase, exactly like a stack trace. Real prose never opens with a+# brace, so this does not touch a humanized readback (which reads "Erledigt — …").+RAW_REPR_OPENER_RE = re.compile(r"^\s*[\{\[]")+REPR_SIGNATURE_RE = re.compile(+ r"['\"][^'\"]{0,120}['\"]\s*:" # 'key': / "key": (JSON or Python dict repr)+ r"|\b\w+\s*=\s*['\"]" # key='…' (Python kwargs/obj repr)+)+# Tool-call patterns:# 1) tool_name({"...": "..."}) — function-call form (OpenAI)# 2) tool_name{"...": "..."} — Anthropic tool-use inline@@ -369,6 +392,20 @@ def scrub_for_voice(fallback_used=True,)+ # 1b. Raw data-structure dump: Early-Return mit Standard-Phrase. A text that+ # OPENS with a container ({ / [) AND carries a mapping signature is a+ # machine repr (a str()'d tool-result dict / JSON array), never a spoken+ # sentence. Fail-closed at the common chokepoint so NO path — present or+ # future — can ever speak/show a raw {'…': …} dump again (live bug+ # 2026-06-22: the whole dispatch_to_harness result reached a CU readback).+ if RAW_REPR_OPENER_RE.match(text) and REPR_SIGNATURE_RE.search(text):+ fallback = FALLBACK_PHRASES.get(language, FALLBACK_PHRASES["de"])+ return ScrubResult(+ cleaned=fallback,+ actions=["replaced_raw_repr"],+ fallback_used=True,+ )+out = text# 0. Hang-up control sentinel: the brain appends END_CALL_SIGNAL to signaldiff --git a/tests/unit/brain/test_computer_use_offload.py b/tests/unit/brain/test_computer_use_offload.pyindex 13d51db6bb..15cd745b01 100644--- a/tests/unit/brain/test_computer_use_offload.py+++ b/tests/unit/brain/test_computer_use_offload.py@@ -78,7 +78,20 @@ async def test_computer_use_acks_immediately_not_blocking_on_harness(monkeypatch@pytest.mark.asyncioasync def test_computer_use_result_announced_when_done(monkeypatch) -> None:bus = _FakeBus()- executor = _SlowHarnessExecutor(output="Chrome ist offen.", delay=0.2)+ # dispatch_to_harness ALWAYS returns a DICT (never a bare string); a verified+ # success carries the on-screen observation in stdout's "(verified: ...)"+ # line. That proof is forwarded as the readback — and the raw dict is NEVER+ # str()'d into the turn (regression for the 2026-06-22 dict-leak, fully+ # covered in test_cu_readback_language.test_success_readback_never_leaks_raw_harness_dict).+ output = {+ "harness": "screenshot",+ "exit_code": 0,+ "stdout": "[cu] done at step 3.1 (verified: Chrome ist offen.)",+ "stderr": "",+ "cost_usd": 0.0,+ "duration_ms": 1200,+ }+ executor = _SlowHarnessExecutor(output=output, delay=0.2)mgr = _make_manager(executor, bus)plan = LocalActionPlan(mode=LocalActionMode.COMPUTER_USE, harness="computer-use", prompt="open chrome"@@ -91,8 +104,13 @@ async def test_computer_use_result_announced_when_done(monkeypatch) -> None:assert executor.calledcompletions = [e for e in bus.published if getattr(e, "kind", None) == "completion"]assert any("Chrome ist offen." in getattr(e, "text", "") for e in completions), (- f"result must be spoken as a completion announcement; got {bus.published}"+ f"the verified observation must be forwarded as the completion; got {bus.published}")+ # The raw harness dict must never leak into the spoken/chat completion.+ assert all(+ "{" not in getattr(e, "text", "") and "exit_code" not in getattr(e, "text", "")+ for e in completions+ ), f"raw harness dict leaked into completion: {bus.published}"@pytest.mark.asynciodiff --git a/tests/unit/brain/test_cu_readback_language.py b/tests/unit/brain/test_cu_readback_language.pyindex 3304d13d08..d8867d72fb 100644--- a/tests/unit/brain/test_cu_readback_language.py+++ b/tests/unit/brain/test_cu_readback_language.py@@ -168,6 +168,55 @@ async def test_cu_failure_announcement_carries_technical_detail() -> None:assert "guard-blocked actions" in comp.detail+async def test_success_readback_never_leaks_raw_harness_dict() -> None:+ """Live bug 2026-06-22 (voice "geh in die Einstellungen und öffne Bluetooth").++ The deterministic CU local-action gate's SUCCESS branch did+ ``str(result.output)`` on the ``dispatch_to_harness`` DICT, so the user heard+ /saw the raw repr ``{'harness': 'screenshot', 'exit_code': 0, 'stdout': ...,+ 'cost_usd': ..., 'duration_ms': ...}`` (the empty ``''`` key in the leak being+ ``scrub_for_voice`` later stripping the blacklisted word "harness"). The+ success branch must humanize via :func:`cu_success_readback` exactly like the+ failure branch humanizes via :func:`cu_failure_readback` and like the+ ``computer_use`` tool path — FORWARD the verified on-screen observation, never+ the dict. ``comp.text`` here is the RAW bus text (scrubbing runs downstream),+ so a leak still carries the dict braces + the word "screenshot".+ """+ bus = _FakeBus()+ # Exactly the shape dispatch_to_harness returns on a verified success.+ output = {+ "harness": "screenshot",+ "exit_code": 0,+ "stdout": (+ "[cu] step 5.1: click_element {name='Bluetooth und Geräte'}\n"+ "[cu] done at step 6.1 (verified: The Windows Settings app is open "+ "to the 'Bluetooth und Geräte' page)"+ ),+ "stderr": "[cu] mission profile: steps=6 total=15.4s act=3.0s observe=0.8s",+ "cost_usd": 0.0,+ "duration_ms": 15442,+ }+ mgr = _make_manager(_CUExecutor(success=True, output=output), bus)+ await mgr._run_computer_use_background(+ tool=object(), harness_name="screenshot",+ prompt="öffne meine bluetooth einstellungen",+ timeout_s=180.0, user_text="geh in meine einstellungen und öffne bluetooth",+ trace_id=uuid4(), lang="de",+ )+ comp = _completion(bus)+ text = comp.text+ # The raw harness dict must NEVER reach the readback.+ assert "{" not in text and "}" not in text, text+ for leaked in (+ "exit_code", "cost_usd", "duration_ms", "stdout", "stderr", "screenshot",+ ):+ assert leaked not in text, f"leaked '{leaked}': {text!r}"+ # The verified on-screen observation IS forwarded as the answer.+ assert "Bluetooth und Geräte" in text, text+ assert comp.language == "de"++@pytest.mark.asyncioasync def test_cu_success_announcement_has_no_detail() -> None:"""A successful run has no failure diagnostic — ``detail`` stays None so thediff --git a/tests/unit/brain/test_output_filter.py b/tests/unit/brain/test_output_filter.pyindex 66f52d5396..6f14544788 100644--- a/tests/unit/brain/test_output_filter.py+++ b/tests/unit/brain/test_output_filter.py@@ -659,3 +659,105 @@ def test_scrub_sentinel_only_yields_empty() -> None:result = scrub_for_voice(END_CALL_SIGNAL, language="de")assert result.cleaned == ""+++# ---------------------------------------------------------------------------+# Raw data-structure dump guard (live bug 2026-06-22).+#+# A code path str()'d a whole tool-result DICT instead of humanizing it, and+# scrub_for_voice — which only knew SPECIFIC tool-leak shapes ({"tool":…},+# XML tags, YAML, prose) — passed it through, stripping only the jargon word+# "harness" (hence the leaked empty '' key). A raw Python/JSON data-structure+# dump must NEVER be spoken/shown, regardless of its keys or quote style. This+# is the fail-closed common-chokepoint defense that makes the bug class+# impossible no matter which path forgets to humanize its output.+# ---------------------------------------------------------------------------+++def test_scrub_replaces_raw_harness_result_dict_with_fallback() -> None:+ """The exact leaked shape from the live bug -> fallback, never spoken."""+ from jarvis.brain.output_filter import FALLBACK_PHRASES++ leaked = (+ "{'harness': 'screenshot', 'exit_code': 0, 'stdout': \"[cu] done at "+ "step 6.1 (verified: Settings open)\", 'stderr': '[cu] mission profile: "+ "steps=6 total=15.4s', 'cost_usd': 0.0, 'duration_ms': 15442}"+ )+ result = scrub_for_voice(leaked, language="de")+ assert result.fallback_used is True+ assert result.cleaned == FALLBACK_PHRASES["de"]+ for leak in ("{", "}", "exit_code", "cost_usd", "duration_ms", "screenshot"):+ assert leak not in result.cleaned, leak+++def test_scrub_replaces_already_scrubbed_harness_dict() -> None:+ """Even the post-jargon form ({'' : 'screenshot', …} — what actually+ reached the user) must be refused, not merely have 'harness' removed."""+ from jarvis.brain.output_filter import FALLBACK_PHRASES++ leaked = "{'': 'screenshot', 'exit_code': 0, 'cost_usd': 0.0, 'duration_ms': 15442}"+ result = scrub_for_voice(leaked, language="de")+ assert result.fallback_used is True+ assert result.cleaned == FALLBACK_PHRASES["de"]+++def test_scrub_refuses_arbitrary_dict_dump_unknown_keys() -> None:+ """STRUCTURAL guard: a brand-new result shape with keys never seen before+ is refused too — no key-by-key whack-a-mole."""+ from jarvis.brain.output_filter import FALLBACK_PHRASES++ leaked = "{'foo': 1, 'bar': 'baz', 'nested': {'a': 2}, 'when': 'now'}"+ result = scrub_for_voice(leaked, language="en")+ assert result.fallback_used is True+ assert result.cleaned == FALLBACK_PHRASES["en"]+++def test_scrub_refuses_json_list_of_objects_dump() -> None:+ """A JSON array of objects (double quotes) is a dump too."""+ from jarvis.brain.output_filter import FALLBACK_PHRASES++ leaked = '[{"title": "X", "snippet": "y"}, {"title": "Z", "snippet": "w"}]'+ result = scrub_for_voice(leaked, language="de")+ assert result.fallback_used is True+ assert result.cleaned == FALLBACK_PHRASES["de"]+++def test_fallback_phrase_localized_to_spanish() -> None:+ """Runtime-output-language doctrine: every phrase table carries all+ supported locales (de/en/es). A Spanish-pinned user must hear the Spanish+ fallback, not German — true for BOTH the raw-dump guard and the stacktrace+ guard (same FALLBACK_PHRASES table)."""+ from jarvis.brain.output_filter import FALLBACK_PHRASES++ assert "es" in FALLBACK_PHRASES, "Spanish fallback phrase missing"+ # raw-dump guard in Spanish+ dump = scrub_for_voice("{'exit_code': 0, 'cost_usd': 0.0}", language="es")+ assert dump.fallback_used is True+ assert dump.cleaned == FALLBACK_PHRASES["es"]+ # stacktrace guard in Spanish (same table)+ trace = scrub_for_voice(+ "Traceback (most recent call last):\n File x\nValueError: boom",+ language="es",+ )+ assert trace.fallback_used is True+ assert trace.cleaned == FALLBACK_PHRASES["es"]+ # the Spanish phrase is actually Spanish, not the German default+ assert dump.cleaned != FALLBACK_PHRASES["de"]+++def test_scrub_keeps_humanized_readback_with_quotes() -> None:+ """No false positive: a clean readback that merely quotes a UI label (and+ contains an apostrophe + colon-free) must pass through untouched."""+ text = "Erledigt — die Einstellungen sind auf 'Bluetooth und Geräte' offen."+ result = scrub_for_voice(text, language="de")+ assert result.fallback_used is False+ assert "Bluetooth und Geräte" in result.cleaned+++def test_scrub_keeps_sentence_with_inline_brace_not_a_dump() -> None:+ """A sentence that happens to mention a brace mid-text is NOT a dump (it+ does not OPEN with a container) — must pass."""+ text = "Ich habe die Funktion test() geprüft, alles in Ordnung."+ result = scrub_for_voice(text, language="de")+ assert result.fallback_used is False+ assert "test()" in result.cleaned or "test" in result.cleaned