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(realtime): keep delegated jarvis_action turns in the resolved output language
Ruben Lütked3863a796f81
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.pyindex 11785b4d4f..7732d357fe 100644--- a/jarvis/brain/manager.py+++ b/jarvis/brain/manager.py@@ -7271,6 +7271,7 @@ class BrainManager:emit_tool_ack: bool = True,publish_response: bool = True,history_override: Iterable[BrainMessage] | None = None,+ force_output_language: str | None = None,) -> str:"""Generate a turn, optionally leaving its public response event to the caller.@@ -7298,6 +7299,7 @@ class BrainManager:allow_voice_confirm=allow_voice_confirm,prefer_tool_model=prefer_tool_model,emit_tool_ack=emit_tool_ack,+ force_output_language=force_output_language,)finally:# Keep the last completed turn inspectable for diagnostics/tests,@@ -7323,6 +7325,7 @@ class BrainManager:allow_voice_confirm: bool = False,prefer_tool_model: bool = False,emit_tool_ack: bool = True,+ force_output_language: str | None = None,) -> str:# 1. Intercept meta-commands (cancel, switch, depth override).# User request 2026-04-25: no standardised confirmation phrases@@ -7358,6 +7361,21 @@ class BrainManager:# reply_language pin leaves it empty -> the directive uses the pin.self._update_turn_language(user_text)+ # Realtime-delegate language override (live 2026-07-23): the realtime+ # session is the ONE authoritative resolver for a voice turn — its own+ # model reply and the recorded jarvis_lang already consume that decision.+ # A delegated jarvis_action turn must speak the SAME language instead of+ # re-deriving it here from a possibly code-switched transcript, which let+ # an English realtime conversation answer a memory-save turn in German+ # ("Notiert ..."). Pin the caller-forced language so+ # _reply_language_directive() hard-locks it; an explicit+ # brain.reply_language pin still wins (checked first in that directive).+ if (+ force_output_language in _REPLY_LANG_NAMES+ and self._reply_language not in _REPLY_LANG_NAMES+ ):+ self._turn_detected_lang = force_output_language+# Two-turn voice/chat confirmation resume (turn N+1). MUST run before the# cancel-intent intercept: a "nein"/"stop" answer to a pending# confirmation is a VETO of that one action, not a global cancel-all.diff --git a/jarvis/brain/router.py b/jarvis/brain/router.pyindex acb67ffcc8..ff75a58be2 100644--- a/jarvis/brain/router.py+++ b/jarvis/brain/router.py@@ -220,8 +220,12 @@ SKILLS — ZUERST PRUEFEN, BEVOR DU ANTWORTEST ODER DELEGIERST (HOHE PRIORITAET)MERKEN / SPEICHERN — DEINE EIGENE INTELLIGENZ-AUFGABE (KEIN TOOL):Du entscheidest selbst was Ruben fuer immer wissen soll. Beginne deine- Antwort mit "Notiert" (gefolgt von einer kurzen 1-Satz-Bestaetigung)- WENN Ruben eine der folgenden Informationen aeussert:+ Antwort mit dem Bestaetigungswort IN DEINER ANTWORTSPRACHE — "Notiert" auf+ Deutsch, "Noted" auf Englisch, "Anotado" auf Spanisch — gefolgt von einer+ kurzen 1-Satz-Bestaetigung in derselben Sprache. Waehle das Wort NIE nach+ der Sprache dieses Prompts, immer nach der Sprache, in der du Ruben in DIESEM+ Turn antwortest (die Reply-Language-Regel weiter unten gewinnt). Nutze diesen+ Praefix WENN Ruben eine der folgenden Informationen aeussert:• Person + Eigenschaft ("Harald ist 1976 geboren", "Anna ist meine Schwester")• Projekt oder Vorhaben ("Ich arbeite an einem Pixel-Art-Editor",@@ -236,7 +240,7 @@ MERKEN / SPEICHERN — DEINE EIGENE INTELLIGENZ-AUFGABE (KEIN TOOL):• API-Key / Setup-Fakt ("Neuer Google-Ace API Key ist erstellt")• Eine konkrete Erkenntnis ("Mir ist aufgefallen dass X Y bedeutet")- Antworte NICHT mit "Notiert" bei:+ Antworte NICHT mit dem Bestaetigungswort ("Notiert"/"Noted"/"Anotado") bei:• Smalltalk, Greeting, Frage, Status-Abfrage• Aktions-Imperativ ("Mach mir...", "Oeffne...") — AUCH in eingebetteter Form("ich moechte, dass du mir X aufmachst/oeffnest/zeigst", "hilf mir, X zu@@ -256,7 +260,8 @@ MERKEN / SPEICHERN — DEINE EIGENE INTELLIGENZ-AUFGABE (KEIN TOOL):WICHTIG: Ruben muss NIE "merk dir bitte" sagen. Du erkennst selbstwas speichernswert ist. Die Memory-Pipeline laeuft passiv im Hintergrund- — dein "Notiert"-Praefix am Antwort-Anfang ist das Signal an die Pipeline,+ — dein Bestaetigungswort-Praefix ("Notiert"/"Noted"/"Anotado", je nach+ Antwortsprache) am Antwort-Anfang ist das Signal an die Pipeline,den User-Satz an den Wiki-Kurator zu schicken. Du rufst KEIN Tool auf.Der alte memory-save-Skill ist deaktiviert; ignoriere ihn komplett.@@ -333,8 +338,9 @@ Du sortierst jede Ruben-Nachricht in genau eine von drei Kategorien:auf..."). A deterministic gate enforces this and will reject the call.- Shell-Kommando: "ls im Desktop", "starte notepad" (run_shell)- Bildschirm beschreiben: "was siehst du auf meinem Screen" (screenshot)- - "merk dir X": KEIN Tool — beginne deine Antwort mit "Notiert" (siehe- MERKEN-Sektion oben); die Memory-Pipeline speichert es im Hintergrund.+ - "merk dir X": KEIN Tool — beginne deine Antwort mit dem+ Bestaetigungswort in deiner Antwortsprache ("Notiert"/"Noted"/"Anotado",+ siehe MERKEN-Sektion oben); die Memory-Pipeline speichert es im Hintergrund.- FRISCHE/aktuelle Fakten oder ausdrueckliche Web-Suche ("was sind dieaktuellsten News", "google das mal", "such im Netz", "aktuellerBitcoin-Preis", "heutiges Wetter"): rufe search_web mit einer praezisendiff --git a/jarvis/memory/wiki/voice_bridge.py b/jarvis/memory/wiki/voice_bridge.pyindex e35f1b7c3d..41f53245c6 100644--- a/jarvis/memory/wiki/voice_bridge.py+++ b/jarvis/memory/wiki/voice_bridge.py@@ -92,7 +92,7 @@ def _turn_hash(text: str) -> str:# Keywords (lowercase, simple substring match) that mark the brain's# reply as "yes, I stored this". Keep narrow -- false positives mean# noise in the wiki; false negatives are caught by the aggressive path.-_ACK_KEYWORDS = ( # i18n-allow: German acknowledgement-phrase matching vocabulary+_ACK_KEYWORDS = ( # i18n-allow: multilingual acknowledgement-phrase matching vocabulary"notiert","vermerkt","gespeichert", # i18n-allow: German acknowledgement-phrase matching vocabulary@@ -101,6 +101,9 @@ _ACK_KEYWORDS = ( # i18n-allow: German acknowledgement-phrase matching vocabula"noted","got it","saved",+ "anotado", # i18n-allow: Spanish acknowledgement-phrase matching vocabulary+ "guardado", # i18n-allow: Spanish acknowledgement-phrase matching vocabulary+ "apuntado", # i18n-allow: Spanish acknowledgement-phrase matching vocabulary)# Minimum length for the ack path to consider the user utterance worthdiff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.pyindex 7d0c82f866..196c1e9080 100644--- a/jarvis/realtime/session.py+++ b/jarvis/realtime/session.py@@ -4800,6 +4800,15 @@ class RealtimeVoiceSession:"publish_response": False,"use_history": False,"history_override": tuple(self._delegate_history),+ # This session already resolved the turn's output language+ # (self._language drives our own model reply and the recorded+ # jarvis_lang). Hand that decision to the delegate so a+ # jarvis_action turn cannot re-derive a different language from a+ # code-switched transcript and answer in the wrong one (live+ # 2026-07-23: an English conversation whose memory-save turns+ # were spoken in German). Unsupported by older managers -> the+ # signature filter below simply drops it.+ "force_output_language": self._language,}try:signature = inspect.signature(generate)diff --git a/tests/unit/brain/test_forced_output_language.py b/tests/unit/brain/test_forced_output_language.pynew file mode 100644index 0000000000..f1d9f94a67--- /dev/null+++ b/tests/unit/brain/test_forced_output_language.py@@ -0,0 +1,147 @@+"""Realtime-delegate output-language override (live forensic 2026-07-23).++Root cause this guards against: a realtime voice conversation resolved to+English (the realtime session's own model reply and the recorded ``jarvis_lang``+both said ``en``), but a ``jarvis_action`` turn was delegated to the classic+BrainManager, which RE-DERIVED the language from the transcript. On a memory-+save turn the German-only router prompt then made it answer "Notiert ..." in+German — two layers, one turn, two languages (the "no layer re-derives the+language" doctrine violation).++The fix: the realtime session hands the delegate its own resolved output+language via ``generate(..., force_output_language=...)``; the manager pins it+so ``_reply_language_directive`` hard-locks that language instead of the+transcript's detected one. An explicit ``brain.reply_language`` pin still wins.+"""+from __future__ import annotations++from collections.abc import AsyncIterator+from uuid import uuid4++import pytest++from jarvis.brain.manager import BrainManager+from jarvis.brain.streaming import StreamingAggregate+from jarvis.core.bus import EventBus+from jarvis.core.config import JarvisConfig+from jarvis.core.protocols import BrainDelta, BrainRequest++# A statement whose text alone detects as German, and one that detects as+# English — the two sides of the code-switch that made the delegate diverge.+_GERMAN_FACT = "Mein Bruder heisst Tom und wohnt schon lange in Berlin" # i18n-allow: German test fixture — the German half of the code-switch under test+_ENGLISH_FACT = "My brother is a doctor and he lives here with me now"+++class _FakeBrain:+ name = "fake"+ context_window = 8192+ supports_tools = True+ supports_vision = False++ async def complete(self, req: BrainRequest) -> AsyncIterator[BrainDelta]:+ yield BrainDelta(content="ok")+ yield BrainDelta(finish_reason="stop")+++class _RecordingDispatcher:+ def __init__(self) -> None:+ self.calls: list[dict] = []++ async def dispatch(self, user_text, *, images=(), history=None, **_kwargs):+ self.calls.append({"user_text": user_text})+ agg = StreamingAggregate()+ agg.text = "reply"+ agg.finish_reason = "stop"+ return agg+++def _manager(reply_language: str = "auto") -> BrainManager:+ cfg = JarvisConfig()+ cfg.brain.primary = "fake"+ cfg.brain.reply_language = reply_language+ m = BrainManager(config=cfg, bus=EventBus(), tools={})+ m._build_fallback_chain = lambda _l: [("fake", "fake-model")] # type: ignore[method-assign]+ m._get_brain = lambda _n, _mo: _FakeBrain() # type: ignore[method-assign]+ m._build_dispatcher = lambda _b, *, tools_override=None: _RecordingDispatcher() # type: ignore[method-assign]+ return m+++async def test_auto_mode_redetects_german_without_force() -> None:+ """Baseline (the bug): auto mode pins the transcript's own language."""+ m = _manager("auto")+ await m.generate(_GERMAN_FACT, trace_id=uuid4(), use_history=False)+ assert m._turn_detected_lang == "de"+ assert "German" in m._reply_language_directive()+++async def test_force_output_language_overrides_detected_language() -> None:+ """The fix: a forced language beats the transcript's detected one."""+ m = _manager("auto")+ await m.generate(+ _GERMAN_FACT,+ trace_id=uuid4(),+ use_history=False,+ force_output_language="en",+ )+ assert m._turn_detected_lang == "en"+ directive = m._reply_language_directive()+ assert "English" in directive+ assert "MANDATORY" in directive+++async def test_explicit_pin_wins_over_forced_language() -> None:+ """A user's explicit reply-language pin outranks the realtime force."""+ m = _manager("de")+ await m.generate(+ _ENGLISH_FACT,+ trace_id=uuid4(),+ use_history=False,+ force_output_language="en",+ )+ # Pinned mode leaves _turn_detected_lang empty; the directive uses the pin.+ assert "German" in m._reply_language_directive()+++async def test_invalid_force_language_is_ignored() -> None:+ """Garbage force value falls through to normal per-turn detection."""+ m = _manager("auto")+ await m.generate(+ _ENGLISH_FACT,+ trace_id=uuid4(),+ use_history=False,+ force_output_language="klingon",+ )+ assert m._turn_detected_lang == "en"+++def test_router_note_prefix_is_language_relative() -> None:+ """The memory-save prefix must follow the reply language, not the prompt.++ A hardcoded German "Notiert" prefix forced German replies on English+ memory-save turns (the other half of the 2026-07-23 bug). The router+ instruction now names the acknowledgement word in every supported language.+ """+ from jarvis.brain.router import SYSTEM_PROMPT++ assert "Noted" in SYSTEM_PROMPT+ assert "Anotado" in SYSTEM_PROMPT+ # German stays present — it is just no longer the only mandated word.+ assert "Notiert" in SYSTEM_PROMPT+++def test_ack_keywords_cover_all_supported_languages() -> None:+ """The memory-signal detector must fire on the ack word in any language.++ The wiki ack path keys off the brain's acknowledgement word; if the reply+ is English/Spanish the word is not "notiert", so the detector must know the+ other languages' words too, or a non-German memory-save would be missed.+ """+ from jarvis.memory.wiki.voice_bridge import _ACK_KEYWORDS++ assert "notiert" in _ACK_KEYWORDS # de+ assert "noted" in _ACK_KEYWORDS # en+ assert "anotado" in _ACK_KEYWORDS # esdiff --git a/tests/unit/realtime/test_session.py b/tests/unit/realtime/test_session.pyindex 8b2e9ef4ad..4d7c3eb9f6 100644--- a/tests/unit/realtime/test_session.py+++ b/tests/unit/realtime/test_session.py@@ -3999,6 +3999,10 @@ async def test_delegate_call_dispatches_raw_transcript_with_voice_confirm():"publish_response": False,"use_history": False,"history_override": (),+ # The session hands the delegate its own resolved output+ # language so a jarvis_action turn cannot answer in a different+ # language than the rest of the conversation (English here).+ "force_output_language": "en",},)]