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): OpenClaw background readback follows the conversation language, not hardcoded German

Ruben Lütke939571248a4f
diff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.py
index fe848637dd..48f050dced 100644
--- a/jarvis/speech/pipeline.py
+++ b/jarvis/speech/pipeline.py
@@ -2716,21 +2716,27 @@ class SpeechPipeline:
# deliberately-muted session, and the phrases below stay priority
# "normal" → queued behind any current speech, never barging
# mid-utterance (AD-OE5).
+ # Resolve the readback language from the ORIGINAL request utterance
+ # (pin > conversation-stickiness > detected utterance > default) so an
+ # English/Spanish user never hears "Fertig." in German (forensic
+ # 2026-06-23: announcement emitters bypassed the resolver).
+ lang = self._output_language(None, getattr(event, "utterance", "") or "")
+ ph = self._BG_READBACK_PHRASES.get(lang, self._BG_READBACK_PHRASES["en"])
if event.success and event.summary:
summ = event.summary.strip()
if len(summ) > 200:
summ = summ[:200].rsplit(" ", 1)[0] + "…"
- text = f"Fertig. {summ}"
+ text = ph["done_summ"].format(s=summ)
elif event.success:
- text = "Fertig."
+ text = ph["done"]
else:
- err_short = (event.error or "unbekannter Fehler")[:80]
- text = f"Das hat nicht geklappt. {err_short}"
+ err_short = (event.error or ph["unknown_err"])[:80]
+ text = ph["fail"].format(e=err_short)
# Defense-in-Depth: Summary/Error kann aus dem OpenClaw-Pfad kommen
# und Engineering-Tokens (Sub-Agent, Subprocess, MCP) enthalten.
# scrub_for_voice filtert die raus, sonst leakt Worker-Mechanik
# in den Voice-Kanal (vgl. Mandat-Pfad #2 Output-Filter).
- scrubbed = scrub_for_voice(text, language="de")
+ scrubbed = scrub_for_voice(text, language=lang)
if scrubbed.actions:
log.info(
"🧹 Background-Filter: %s (fallback=%s)",
@@ -2757,7 +2763,7 @@ class SpeechPipeline:
AnnouncementRequested(
source_layer="harness.openclaw.background",
text=cleaned,
- language="de",
+ language=lang,
priority="normal",
kind="subagent",
)
@@ -2771,7 +2777,7 @@ class SpeechPipeline:
# through this background path, not _speak, so it would otherwise be
# invisible in the Transcription view. Tagged ``subagent`` so it renders
# on the attributed "Jarvis Sub-Agent / Output" track.
- self._emit_spoken(cleaned, "de", SPOKEN_KIND_SUBAGENT)
+ self._emit_spoken(cleaned, lang, SPOKEN_KIND_SUBAGENT)
# Re-arm the readback grace exactly like ``_on_announcement`` (:2386): a
# background result delivered through THIS direct path also hands the
# floor back to the user, so ``_active_session`` must keep the mic open
@@ -2792,7 +2798,7 @@ class SpeechPipeline:
await self._transition("SPEAKING")
try:
try:
- chunks = self._tts.synthesize(cleaned, language_code="de-DE")
+ chunks = self._tts.synthesize(cleaned, language_code=self._bcp47(lang))
except TypeError:
chunks = self._tts.synthesize(cleaned)
await self._player.play_chunks(chunks)
@@ -6868,6 +6874,31 @@ class SpeechPipeline:
except Exception: # noqa: BLE001 — telemetry must never break the turn
log.debug("SpeechSpoken emit failed", exc_info=True)
+ #: Spoken readback for an OpenClaw background task that finished off the
+ #: chat path. de/en/es so the readback follows the conversation language
+ #: instead of a hardcoded German literal (forensic 2026-06-23). German
+ #: strings are TTS product surface, not source artifacts (i18n-allow).
+ _BG_READBACK_PHRASES: dict[str, dict[str, str]] = {
+ "de": {
+ "done": "Fertig.", # i18n-allow
+ "done_summ": "Fertig. {s}", # i18n-allow
+ "fail": "Das hat nicht geklappt. {e}", # i18n-allow
+ "unknown_err": "unbekannter Fehler", # i18n-allow
+ },
+ "en": {
+ "done": "Done.",
+ "done_summ": "Done. {s}",
+ "fail": "That didn't work. {e}",
+ "unknown_err": "unknown error",
+ },
+ "es": {
+ "done": "Listo.",
+ "done_summ": "Listo. {s}",
+ "fail": "Eso no funcionó. {e}",
+ "unknown_err": "error desconocido",
+ },
+ }
+
_BCP47: dict[str, str] = {"de": "de-DE", "en": "en-US", "es": "es-ES"}
@classmethod
diff --git a/tests/unit/speech/test_announcement_bridge.py b/tests/unit/speech/test_announcement_bridge.py
index e35fdfb255..ac0cc475d3 100644
--- a/tests/unit/speech/test_announcement_bridge.py
+++ b/tests/unit/speech/test_announcement_bridge.py
@@ -268,7 +268,7 @@ async def test_openclaw_background_success_no_summary_speaks_fertig() -> None:
await bus.publish(
OpenClawBackgroundCompleted(
- success=True, utterance="x", summary="", error="", duration_s=1.0,
+ success=True, utterance="mach mir das", summary="", error="", duration_s=1.0,
)
)
@@ -286,7 +286,7 @@ async def test_openclaw_background_failure_speaks_error() -> None:
await bus.publish(
OpenClawBackgroundCompleted(
- success=False, utterance="x", summary="",
+ success=False, utterance="mach mir das", summary="",
error="rate-limit reached", duration_s=2.0,
)
)
@@ -410,7 +410,7 @@ async def test_openclaw_completion_signal_does_speak_with_summary() -> None:
await bus.publish(
OpenClawBackgroundCompleted(
success=True,
- utterance="baue etwas",
+ utterance="baue mir etwas",
summary="Fertig gebaut",
duration_s=1.2,
)
diff --git a/tests/unit/speech/test_background_readback_language.py b/tests/unit/speech/test_background_readback_language.py
new file mode 100644
index 0000000000..b1a6773fa0
--- /dev/null
+++ b/tests/unit/speech/test_background_readback_language.py
@@ -0,0 +1,56 @@
+"""The OpenClaw background-completed readback ("Done." / "That didn't work.")
+must follow the resolved conversation language, not a hardcoded German literal.
+
+Forensic 2026-06-23 family: announcement emitters bypassed the resolver. This
+one hardcoded German text + ``language="de"`` + ``language_code="de-DE"``, so an
+English- or Spanish-speaking user heard "Fertig." in German. The readback now
+resolves the language through ``_conversation_language_for_announcement`` and
+picks a de/en/es phrase, with the matching BCP-47 voice pin.
+"""
+from __future__ import annotations
+
+from types import SimpleNamespace
+
+import pytest
+
+from jarvis.core.bus import EventBus
+from jarvis.core.events import OpenClawBackgroundCompleted
+from tests.unit.speech.test_announcement_bridge import (
+ FakePlayer,
+ FakeTTS,
+ _make_pipeline,
+)
+
+
+async def test_background_readback_speaks_english_for_english_conversation() -> None:
+ bus = EventBus()
+ tts = FakeTTS()
+ pipe = _make_pipeline(tts, bus, FakePlayer())
+ pipe._brain = SimpleNamespace(reply_language="auto", conversation_language="en")
+
+ await bus.publish(
+ OpenClawBackgroundCompleted(success=True, summary="", duration_s=1.0)
+ )
+
+ assert tts.calls, "expected a background readback to be synthesized"
+ text, lang_code = tts.calls[-1]
+ assert lang_code == "en-US"
+ assert "Fertig" not in text
+
+
+async def test_background_readback_stays_german_for_german_conversation() -> None:
+ bus = EventBus()
+ tts = FakeTTS()
+ pipe = _make_pipeline(tts, bus, FakePlayer())
+ pipe._brain = SimpleNamespace(reply_language="auto", conversation_language="de")
+
+ await bus.publish(
+ OpenClawBackgroundCompleted(success=True, summary="", duration_s=1.0)
+ )
+
+ assert tts.calls, "expected a background readback to be synthesized"
+ text, lang_code = tts.calls[-1]
+ assert lang_code == "de-DE"
+ assert "Fertig" in text