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): unpin the flash model and localize the failure cause
Harald6834efba8113
diff --git a/jarvis/brain/ack_brain/config.py b/jarvis/brain/ack_brain/config.pyindex f52e4da8c0..774b1f8392 100644--- a/jarvis/brain/ack_brain/config.py+++ b/jarvis/brain/ack_brain/config.py@@ -77,8 +77,15 @@ class _ProvidersBundle(BaseModel):# before use, so retaining forward-compatible data is safe here.model_config = ConfigDict(extra="allow")+ # The rolling alias, NOT a pinned generation. A hardcoded version name is+ # exactly how this slot broke: "gemini-3.1-flash" is absent from the AI+ # Studio catalog (probed live 2026-08-20 — it serves 3.1-flash-lite,+ # 3.5/3.6/3.7-flash and the aliases, but no plain 3.1-flash), so EVERY ack+ # and every contextual readback 404'd and silently fell back to the canned+ # table on any install using a Gemini key. The alias cannot go stale, and a+ # one-sentence ack has no capability requirement that would justify a pin.gemini: GeminiAckProviderConfig = Field(- default_factory=lambda: GeminiAckProviderConfig(model="gemini-3.1-flash")+ default_factory=lambda: GeminiAckProviderConfig(model="gemini-flash-latest"))grok: GrokAckProviderConfig = Field(default_factory=lambda: GrokAckProviderConfig(diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.pyindex 6694029922..e7124c1b6f 100644--- a/jarvis/brain/manager.py+++ b/jarvis/brain/manager.py@@ -92,6 +92,7 @@ from jarvis.voice.action_phrases import (cu_failure_readback,cu_success_readback,extract_speakable_reason,+ localize_failure_reason,)from jarvis.voice.contextual_readback import render_readback@@ -8480,7 +8481,15 @@ class BrainManager:if reason:facts: dict[str, object] | None = {"reason": reason}instruction = f"{situation} The reason given was: {reason}"- canned = lambda: action_phrase(reason_key, lang, reason=reason) # noqa: E731+ # The composer rephrases the English cause itself — but only while+ # it has a live model. The canned floor gets the cause already in+ # the turn's language, so a dead flash slot cannot produce a+ # half-translated sentence (live 2026-08-20: the Gemini ack slot+ # answered 404 and then 429, and every readback came out canned).+ spoken_reason = localize_failure_reason(reason, lang)+ canned = lambda: action_phrase( # noqa: E731+ reason_key, lang, reason=spoken_reason+ )else:facts = Noneinstruction = situation@@ -9626,7 +9635,10 @@ class BrainManager:"failed",pending.tool_name,language=pending.lang,- detail=extract_speakable_reason(str(exc), None),+ detail=localize_failure_reason(+ extract_speakable_reason(str(exc), None), pending.lang+ )+ or None,)kind = "done" if getattr(result, "success", False) else "failed"return format_confirm_outcome(@@ -9638,11 +9650,17 @@ class BrainManager:if kind == "done"# Raw ``error`` is routinely the opaque ``exit N`` token the# tool layer emits; the gate turns that into no detail at- # all rather than a machine word in the user's ear.- else extract_speakable_reason(- getattr(result, "error", None),- getattr(result, "output", None),+ # all rather than a machine word in the user's ear. There is+ # no composer on this path at all, so the cause is localized+ # deterministically or it stays English forever.+ else localize_failure_reason(+ extract_speakable_reason(+ getattr(result, "error", None),+ getattr(result, "output", None),+ ),+ pending.lang,)+ or None),)diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.pyindex 0b731d7828..cf94d65299 100644--- a/jarvis/realtime/session.py+++ b/jarvis/realtime/session.py@@ -8403,7 +8403,10 @@ class RealtimeVoiceSession:when a cause exists, ``generic_key`` when the tool genuinely gavenone. Never empty, never a hardcoded German string on an en/es turn."""- from jarvis.voice.action_phrases import action_phrase+ from jarvis.voice.action_phrases import (+ action_phrase,+ localize_failure_reason,+ )from jarvis.voice.contextual_readback import render_readbacklanguage = language or self._language@@ -8412,7 +8415,7 @@ class RealtimeVoiceSession:instruction = f"{situation} The reason reported was: {reason}"facts: dict[str, object] | None = {"reason": reason}canned = lambda: action_phrase( # noqa: E731- "action_failed_reason", language, reason=reason+ "action_failed_reason", language, reason=spoken_reason)else:instruction = situation@@ -8453,6 +8456,11 @@ class RealtimeVoiceSession:await self._publish_turn_completed()# Between this boundary and the transcript there is no open turn, yet the# user is audibly mid-utterance: no follow-up may take the floor here.+ # The composer rephrases the English cause itself — but only while+ # it has a live model. The canned floor gets the cause already in+ # the turn's language, so a dead flash slot cannot produce the+ # half-German sentence of 2026-08-20.+ spoken_reason = localize_failure_reason(reason, language)self._user_speech_active = True# Do not open the next persisted turn on VAD alone. A cancelled provider# response can still emit response.done after barge-in; opening here woulddiff --git a/jarvis/voice/action_phrases.py b/jarvis/voice/action_phrases.pyindex 83f1a58043..08b766884b 100644--- a/jarvis/voice/action_phrases.py+++ b/jarvis/voice/action_phrases.py@@ -860,6 +860,105 @@ def _is_speakable_observation(text: str | None) -> bool:return _CU_VERIFIER_DUMP_RE.search(text or "") is None+#: Failure families OUR OWN tools emit, mapped to a spoken sentence per+#: language. Tool error strings are English by contract (CLAUDE.md §1: the+#: model rephrases them for the user), but the rephrasing model is not always+#: there — no ``[ack_brain]`` provider, a dead key, an exhausted quota, the+#: breaker open. Live 2026-08-20: the Gemini flash slot answered 404 (stale+#: pinned model) and then 429 (credits gone), so EVERY readback came out of the+#: canned table and a German turn spoke the failure line with the cause still+#: in English — half the sentence in the wrong language.+#:+#: These are OUR strings with OUR wording, so the mapping is a deterministic+#: regex table, not a translator (AP-11: no LLM on this path). An unknown+#: reason — any third-party plugin's own text — is passed through verbatim,+#: because a foreign-language cause still beats no cause at all.+_REASON_FAMILIES: tuple[tuple[re.Pattern[str], dict[str, str]], ...] = (+ (+ re.compile(+ r"^(?P<subject>[\w .&'’-]{2,40}?)\s+is not connected\b.*$",+ re.IGNORECASE | re.DOTALL,+ ),+ {+ "de": "{subject} ist nicht verbunden. " # i18n-allow+ "Verbinde es in der Plugins-Ansicht.", # i18n-allow+ "en": "{subject} is not connected. Connect it in the Plugins view.",+ "es": "{subject} no está conectado. Conéctalo en la vista de Plugins.",+ },+ ),+ (+ re.compile(+ r"^(?P<subject>[\w .&'’-]{2,40}?)\s+authorization expired\b.*$",+ re.IGNORECASE | re.DOTALL,+ ),+ {+ "de": "Die Anmeldung bei {subject} ist abgelaufen. " # i18n-allow+ "Verbinde es in der Plugins-Ansicht neu.", # i18n-allow+ "en": "The sign-in for {subject} expired. Reconnect it in the Plugins view.",+ "es": "La sesión de {subject} caducó. Vuelve a conectarlo en la vista de Plugins.",+ },+ ),+ (+ re.compile(r"^Unknown skill:\s*(?P<subject>[^.]{1,60})\.?.*$", re.DOTALL),+ {+ "de": "Ich kenne keinen Skill namens {subject}.", # i18n-allow+ "en": "I don't know a skill called {subject}.",+ "es": "No conozco ninguna skill llamada {subject}.",+ },+ ),+ (+ re.compile(+ r"^Skill '(?P<subject>[^']{1,60})' is in DRAFT state\b.*$", re.DOTALL+ ),+ {+ "de": "Der Skill {subject} ist noch ein Entwurf. Gib ihn erst frei.", # i18n-allow+ "en": "The skill {subject} is still a draft. Promote it first.",+ "es": "La skill {subject} sigue siendo un borrador. Actívala primero.",+ },+ ),+ (+ re.compile(+ r"^Skill '(?P<subject>[^']{1,60})' is DISABLED\b.*$", re.DOTALL+ ),+ {+ "de": "Der Skill {subject} ist ausgeschaltet. " # i18n-allow+ "Schalte ihn erst wieder ein.", # i18n-allow+ "en": "The skill {subject} is switched off. Switch it back on first.",+ "es": "La skill {subject} está desactivada. Vuelve a activarla primero.",+ },+ ),+)+++def localize_failure_reason(reason: str | None, language: str) -> str:+ """Speak a KNOWN failure cause in the turn's language; pass others through.++ The deterministic floor under the contextual composer. When the composer+ is alive it rephrases the cause itself and this table never shows; when it+ is not — and on the 2026-08-20 dev box it was not, twice over — this is+ what keeps a German turn from ending in an English clause.++ Returns ``""`` for an empty input, the mapped sentence for a family in+ :data:`_REASON_FAMILIES`, and the input unchanged for anything else.+ """+ text = " ".join(str(reason or "").split())+ if not text:+ return ""+ lang = str(language or "").strip().lower()+ for pattern, templates in _REASON_FAMILIES:+ match = pattern.match(text)+ if match is None:+ continue+ # Same language resolution as ``action_phrase``: an unknown code falls+ # back to the module default, never to a half-translated sentence.+ template = templates.get(lang) or templates[_DEFAULT]+ subject = " ".join(match.group("subject").split()).strip("'\" ")+ if not subject:+ continue+ return template.format(subject=subject)+ return text++def extract_speakable_reason(error: str | None, output: object = None) -> str | None:"""Pull a clean, user-facing failure reason out of a tool result, or ``None``.@@ -986,6 +1085,7 @@ __all__ = ["cu_failure_readback","cu_success_readback","extract_speakable_reason",+ "localize_failure_reason","resolve_ambient_language","resolve_phrase_language",]diff --git a/tests/unit/brain/test_voice_confirm_flow.py b/tests/unit/brain/test_voice_confirm_flow.pyindex 781eea1dfb..a3f30657cc 100644--- a/tests/unit/brain/test_voice_confirm_flow.py+++ b/tests/unit/brain/test_voice_confirm_flow.py@@ -162,7 +162,9 @@ async def test_confirmed_failure_names_the_reason() -> None:mgr = _manager(_ReasonExecutor())_arm(mgr, uuid4())out = await mgr._resume_voice_confirm("ja")- assert "Gmail is not connected" in out+ # Spoken in the pending turn's language, so assert the fact:+ assert "Gmail" in out+ assert "Plugins" in out@pytest.mark.asynciodiff --git a/tests/unit/realtime/test_failure_line_states_the_reason.py b/tests/unit/realtime/test_failure_line_states_the_reason.pyindex 1462bd12e8..03a31d3728 100644--- a/tests/unit/realtime/test_failure_line_states_the_reason.py+++ b/tests/unit/realtime/test_failure_line_states_the_reason.py@@ -167,7 +167,10 @@ async def test_failed_tool_speaks_the_reason_not_the_stock_line() -> None:text, succeeded = await sess._direct_tool_fallback_text()assert succeeded is False- assert GMAIL_REASON in text, "the user must hear WHY the mail call failed"+ # The cause is spoken in the TURN's language (localize_failure_reason), so+ # assert on the fact, not on the tool's English wording.+ assert "Gmail" in text, "the user must hear WHY the mail call failed"+ assert "Plugins" in text, "and what they can do about it"assert text != action_phrase("action_failed_generic", sess._language)@@ -188,7 +191,8 @@ async def test_failed_skill_call_names_the_skill_problem() -> None:text, succeeded = await sess._direct_tool_fallback_text()assert succeeded is False- assert "DRAFT" in text+ assert "morning-routine" in text+ assert text != action_phrase("action_failed_generic", sess._language)@pytest.mark.asynciodiff --git a/tests/unit/voice/test_localize_failure_reason.py b/tests/unit/voice/test_localize_failure_reason.pynew file mode 100644index 0000000000..2fd5a380a5--- /dev/null+++ b/tests/unit/voice/test_localize_failure_reason.py@@ -0,0 +1,117 @@+"""A failure cause must reach the user in the TURN's language, composer or not.++Live 2026-08-20: the realtime path finally forwarded the cause instead of the+stock line — and a German turn then said "Das hat nicht geklappt: Gmail is not # i18n-allow: quotes the mixed-language line this module repairs+connected — connect it in the Plugins view." Half the sentence in the wrong+language, because the contextual composer that was supposed to rephrase the+English tool string was dead twice over: its pinned model (gemini-3.1-flash)+is absent from the AI Studio catalog (404) and the key's credits were gone+(429). The composer is an enhancement; it must never be the only thing between+the user and a comprehensible sentence.++``localize_failure_reason`` is that floor: a deterministic regex table over OUR+OWN tools' error wording (AP-11 — no LLM), passing anything foreign through+unchanged, because a cause in the wrong language still beats no cause.+"""++from __future__ import annotations++import pytest++from jarvis.voice.action_phrases import action_phrase, localize_failure_reason++GMAIL = "Gmail is not connected — connect it in the Plugins view."+CALENDAR_EXPIRED = (+ "Google Calendar authorization expired and could not be renewed — "+ "please reconnect Google Calendar in the Plugins view."+)+++# ---------------------------------------------------------------------------+# The families our own tools emit+# ---------------------------------------------------------------------------+++ ("language", "must_contain"),+ [+ ("de", "Gmail ist nicht verbunden"), # i18n-allow: asserts the German product surface+ ("en", "Gmail is not connected"),+ ("es", "Gmail no está conectado"), # i18n-allow: asserts the Spanish product surface+ ],+)+def test_not_connected_speaks_the_turn_language(language, must_contain) -> None:+ spoken = localize_failure_reason(GMAIL, language)+ assert must_contain in spoken+++def test_not_connected_keeps_the_service_name() -> None:+ for service in ("Gmail", "Google Drive", "Google Calendar", "Home Assistant"):+ spoken = localize_failure_reason(+ f"{service} is not connected — connect it in the Plugins view.", "de"+ )+ assert service in spoken+++def test_expired_authorization_is_a_distinct_sentence() -> None:+ expired = localize_failure_reason(CALENDAR_EXPIRED, "de")+ never = localize_failure_reason(+ "Google Calendar is not connected — connect it in the Plugins view.", "de"+ )+ assert "Google Calendar" in expired+ assert expired != never, "'never connected' and 'token died' are different facts"+++def test_unknown_skill_drops_the_installed_list() -> None:+ spoken = localize_failure_reason(+ "Unknown skill: morgenroutine. Installed skills: a, b, c, d, e", "de"+ )+ assert "morgenroutine" in spoken+ assert "Installed skills" not in spoken, "the whole catalog is not a spoken sentence"+++def test_draft_and_disabled_skills_are_told_apart() -> None:+ draft = localize_failure_reason(+ "Skill 'morning-routine' is in DRAFT state and not invocable. Promote it first.",+ "de",+ )+ disabled = localize_failure_reason(+ "Skill 'morning-routine' is DISABLED and not invocable. Re-enable it first.",+ "de",+ )+ assert "morning-routine" in draft+ assert "morning-routine" in disabled+ assert draft != disabled+++# ---------------------------------------------------------------------------+# Everything else must survive untouched+# ---------------------------------------------------------------------------+++def test_an_unknown_reason_passes_through_verbatim() -> None:+ foreign = "The printer tray is empty and the job was dropped."+ assert localize_failure_reason(foreign, "de") == foreign+++def test_whitespace_is_collapsed_but_content_is_kept() -> None:+ assert localize_failure_reason(" a broken\n thing ", "de") == "a broken thing"+++def test_empty_input_stays_empty() -> None:+ assert localize_failure_reason(None, "de") == ""+ assert localize_failure_reason("", "de") == ""+ assert localize_failure_reason(" ", "de") == ""+++def test_an_unknown_language_falls_back_to_the_module_default() -> None:+ assert localize_failure_reason(GMAIL, "fr") == localize_failure_reason(GMAIL, "de")+++def test_the_localized_cause_fits_the_failure_phrase() -> None:+ """The end product: one sentence, one language."""+ spoken = action_phrase(+ "action_failed_reason", "de", reason=localize_failure_reason(GMAIL, "de")+ )+ assert "is not connected" not in spoken, "no English clause left in a German line"+ assert "Plugins" in spoken, "the actionable part survives"