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
feat(voice): honest spoken failure causes + keep calendar trivia native
Personal Jarvis Maintainer49c14cdba61f
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.pyindex 30e0b83c0a..11785b4d4f 100644--- a/jarvis/brain/manager.py+++ b/jarvis/brain/manager.py@@ -1788,18 +1788,170 @@ _PROVIDER_DOWN_PHRASES: dict[str, tuple[str, ...]] = {}-def _provider_down_phrase(lang: str, idx: int) -> str:- """Localized, provider-agnostic apology for a total brain-chain failure.+# Cause-aware variants of the total-failure apology (maintainer directive+# 2026-07-21: "when such an error happens, SAY what it was about"). One+# spoken sentence per root-cause CATEGORY — still voice-safe (no provider+# names, no URLs, no billing pages; ADR-0010) but honest about WHY, with the+# in-app recovery step. Keys mirror the ``kind`` values classified by the+# provider chain (``_format_provider_chain_error``); an unknown/unlisted kind+# falls back to the generic rotation above.+_PROVIDER_DOWN_CAUSE_PHRASES: dict[str, dict[str, str]] = {+ "missing_key": {+ "de": (+ "Entschuldige — für mein Sprachmodell ist gerade kein " # i18n-allow+ "API-Schlüssel hinterlegt. Öffne in der Seitenleiste die " # i18n-allow+ "API-Keys und trag einen ein, dann geht es sofort weiter." # i18n-allow+ ),+ "en": (+ "Sorry — no API key is set for my language model right now. "+ "Open the API keys in the sidebar and add one, and I can "+ "continue right away."+ ),+ "es": (+ "Lo siento: ahora mismo no hay ninguna clave de API configurada "+ "para mi modelo de lenguaje. Abre las claves de API en la barra "+ "lateral y añade una, y podré continuar enseguida."+ ),+ },+ "bad_key": {+ "de": (+ "Entschuldige — mein hinterlegter API-Schlüssel wird abgelehnt, " # i18n-allow+ "er ist wohl ungültig oder abgelaufen. Bitte ersetze ihn in den " # i18n-allow+ "API-Keys in der Seitenleiste." # i18n-allow+ ),+ "en": (+ "Sorry — my stored API key is being rejected; it looks invalid "+ "or expired. Please replace it under API keys in the sidebar."+ ),+ "es": (+ "Lo siento: mi clave de API almacenada está siendo rechazada; "+ "parece inválida o caducada. Sustitúyela en las claves de API "+ "de la barra lateral."+ ),+ },+ "account_blocked": {+ "de": (+ "Entschuldige — das Konto meines Sprachmodells blockiert gerade, " # i18n-allow+ "vermutlich ist das Guthaben aufgebraucht oder das Limit " # i18n-allow+ "erreicht. Bitte wirf einen Blick auf das Anbieter-Konto." # i18n-allow+ ),+ "en": (+ "Sorry — my language model's account is blocking right now, "+ "most likely the credit is used up or a limit was reached. "+ "Please take a look at the provider account."+ ),+ "es": (+ "Lo siento: la cuenta de mi modelo de lenguaje está bloqueada "+ "ahora mismo; probablemente se agotó el crédito o se alcanzó un "+ "límite. Revisa la cuenta del proveedor, por favor."+ ),+ },+ "rate_limit": {+ "de": (+ "Entschuldige — mein Anbieter bremst mich gerade wegen zu " # i18n-allow+ "vieler Anfragen. Warte einen Moment und frag mich dann " # i18n-allow+ "einfach noch einmal." # i18n-allow+ ),+ "en": (+ "Sorry — my provider is throttling me for too many requests. "+ "Give it a moment and just ask me again."+ ),+ "es": (+ "Lo siento: mi proveedor me está limitando por demasiadas "+ "solicitudes. Espera un momento y vuelve a preguntarme."+ ),+ },+ "invalid_model": {+ "de": (+ "Entschuldige — das eingestellte Modell wird vom Anbieter nicht " # i18n-allow+ "akzeptiert. Bitte prüf die Modell-Auswahl in den Einstellungen." # i18n-allow+ ),+ "en": (+ "Sorry — the configured model is not accepted by the provider. "+ "Please check the model selection in the settings."+ ),+ "es": (+ "Lo siento: el modelo configurado no es aceptado por el "+ "proveedor. Revisa la selección de modelo en los ajustes."+ ),+ },+ "unreachable": {+ "de": (+ "Entschuldige — ich erreiche meinen Anbieter gerade nicht, " # i18n-allow+ "vermutlich ein Netzwerk- oder Anbieterproblem. Versuch es " # i18n-allow+ "gleich bitte noch einmal." # i18n-allow+ ),+ "en": (+ "Sorry — I can't reach my provider right now, likely a network "+ "or provider issue. Please try again in a moment."+ ),+ "es": (+ "Lo siento: no puedo comunicarme con mi proveedor ahora mismo; "+ "probablemente sea un problema de red o del proveedor. Inténtalo "+ "de nuevo en un momento."+ ),+ },+}++# Priority when several providers failed for different reasons — the FIRST+# matching kind names the spoken cause. Mirrors the root-cause ordering of+# ``_format_provider_chain_error`` (missing key beats rate limit, etc.);+# ``skipped_cooldown`` collapses onto rate_limit and network/other onto+# ``unreachable``.+_PROVIDER_DOWN_CAUSE_PRIORITY: tuple[str, ...] = (+ "missing_key",+ "bad_key",+ "account_blocked",+ "invalid_model",+ "rate_limit",+ "unreachable",+)+++def _primary_provider_down_cause(+ errors: list[tuple[str, str, str, str]] | None,+) -> str | None:+ """Map a provider-error list onto the single spoken cause category."""+ if not errors:+ return None+ kinds = {kind for _prov, _model, kind, _detail in errors}+ if "skipped_cooldown" in kinds:+ kinds.add("rate_limit")+ if kinds - {+ "missing_key",+ "bad_key",+ "account_blocked",+ "invalid_model",+ "rate_limit",+ "skipped_cooldown",+ "empty_response",+ }:+ # Any unclassified failure (network, timeout, 5xx) reads as+ # unreachable — the honest generic cause.+ kinds.add("unreachable")+ for cause in _PROVIDER_DOWN_CAUSE_PRIORITY:+ if cause in kinds:+ return cause+ return None+++def _provider_down_phrase(lang: str, idx: int, cause: str | None = None) -> str:+ """Localized apology for a total brain-chain failure, cause-aware.``lang`` is a reply-language code (de/en/es); anything else — notably- "auto" — falls back to German (the default locale). ``idx`` rotates- deterministically through the three variants so repeated failures in one- session don't repeat the identical sentence. Voice-safe by construction:- no provider names, no URLs, no jargon (anti-AP-11 / ADR-0010).+ "auto" — falls back to German (the default locale). When ``cause`` names+ a known failure category, the phrase states WHY and the in-app recovery+ step (maintainer directive 2026-07-21) — still without provider names,+ URLs, or jargon (ADR-0010). Otherwise ``idx`` rotates deterministically+ through the generic variants so repeated failures in one session don't+ repeat the identical sentence."""- variants = _PROVIDER_DOWN_PHRASES.get(- (lang or "").strip().lower(), _PROVIDER_DOWN_PHRASES["de"]- )+ lang_key = (lang or "").strip().lower()+ if cause:+ cause_table = _PROVIDER_DOWN_CAUSE_PHRASES.get(cause)+ if cause_table:+ return cause_table.get(lang_key, cause_table["de"])+ variants = _PROVIDER_DOWN_PHRASES.get(lang_key, _PROVIDER_DOWN_PHRASES["de"])return variants[idx % len(variants)]@@ -2940,21 +3092,24 @@ class BrainManager:lang = getattr(self, "_turn_detected_lang", "") or langreturn lang if lang in _REPLY_LANG_NAMES else "de"- def _next_provider_down_phrase(self) -> str:+ def _next_provider_down_phrase(self, cause: str | None = None) -> str:"""Localized 'I can't reach my model' apology + advance the rotation.- Spoken when the whole provider chain fails. Provider-agnostic and- voice-safe (no names/URLs) — the actionable diagnostic is logged, never- spoken (live complaint 2026-06-01: the grok/Anthropic billing message- was read aloud while Gemini was the active provider).+ Spoken when the whole provider chain fails. ``cause`` (a classified+ failure category) makes the phrase state WHY and the in-app fix —+ still voice-safe, no provider names/URLs — the detailed diagnostic+ stays logged, never spoken (live complaint 2026-06-01: the grok/+ Anthropic billing message was read aloud while Gemini was active)."""phrase = _provider_down_phrase(- self._resolve_turn_lang(), self._provider_down_idx+ self._resolve_turn_lang(), self._provider_down_idx, cause)self._provider_down_idx += 1return phrase- async def _provider_down_reply(self, trace_uuid: UUID) -> str:+ async def _provider_down_reply(+ self, trace_uuid: UUID, cause: str | None = None+ ) -> str:"""Total-failure apology, ALSO surfaced to the transcript.Normal calls publish the phrase as ``ResponseGenerated`` so the@@ -2964,7 +3119,7 @@ class BrainManager:NOT appended to conversation history because a provider outage must notpollute the LLM context for later turns."""- phrase = self._next_provider_down_phrase()+ phrase = self._next_provider_down_phrase(cause)# _next_provider_down_phrase already localized the phrase via# _resolve_turn_lang; resolving again here is deterministic (same pin /# detected-language inputs, the rotation index does not affect language)@@ -7710,7 +7865,8 @@ class BrainManager:)else:log.warning("No brain providers available — spoken fallback used.")- return await self._provider_down_reply(trace_uuid)+ # An all-keyless chain has exactly one honest spoken cause.+ return await self._provider_down_reply(trace_uuid, cause="missing_key")history_override = _TURN_HISTORY_OVERRIDE.get()history = (@@ -8285,7 +8441,9 @@ class BrainManager:"Spoken fallback used instead of chain diagnostic: %s",_format_provider_chain_error(provider_errors),)- return await self._provider_down_reply(trace_uuid)+ return await self._provider_down_reply(+ trace_uuid, cause=_primary_provider_down_cause(provider_errors)+ )# Text-serialized calls are recovered inside BrainDispatcher's shared# ToolUseLoop, where the exact turn-scoped tool surface, deadline,diff --git a/jarvis/brain/turn_planner.py b/jarvis/brain/turn_planner.pyindex def6601ced..7fa386ce6a 100644--- a/jarvis/brain/turn_planner.py+++ b/jarvis/brain/turn_planner.py@@ -240,6 +240,29 @@ _ASSISTANT_DAYPLAN_RE = re.compile(r"\bque (?:haces|estas haciendo)\b"r"(?:[^.?!]{0,24}?\b(?:hoy|manana|ahora)\b)?")+# Calendar trivia: asking which day/weekday/date it is (today/tomorrow/...)+# is answerable by the realtime model itself — the session instructions carry+# the current local date — yet the time word ("morgen", "tomorrow") used to+# read as a CURRENT_DATA freshness marker and force a 12-34 s delegation+# (live complaint 2026-07-21: "Was ist morgen für ein Tag?" # i18n-allow: quoted utterance+# delegated twice). Like the dayplan idiom, the matched span is removed+# before the weak scans; a real freshness topic (weather, news, schedule)+# never matches these shapes and keeps delegating.+_DATE_TRIVIA_RE = re.compile(+ # i18n-allow: multilingual speech-input matching data+ r"\bwas (?:ist|wird|war) (?:heute|morgen|uebermorgen|gestern)" # i18n-allow: speech input+ r"[^.?!]{0,24}?\b(?:tag|wochentag|datum)\b|" # i18n-allow: speech input+ r"\b(?:welcher|welchen|was fuer ein\w*) (?:tag|wochentag)\b" # i18n-allow: speech input+ r"[^.?!]{0,16}?\b(?:ist|haben wir|war)\b(?:[^.?!]{0,16}?" # i18n-allow: speech input+ r"\b(?:heute|morgen|uebermorgen|gestern)\b)?|" # i18n-allow: speech input+ r"\bwelches datum\b(?:[^.?!]{0,12}?\bhaben wir\b)?|" # i18n-allow: speech input+ r"\bder wievielte\b(?:[^.?!]{0,16}?"+ r"\b(?:heute|morgen|uebermorgen|gestern)\b)?|"+ r"\bwhat day (?:is|was)(?: it)?(?: (?:today|tomorrow|yesterday))?\b|"+ r"\bwhat is (?:today|tomorrow|yesterday)(?:'s)? (?:day|date|for day)\b|"+ r"\bwhat(?:'s| is) the (?:date|day)\b(?: (?:today|tomorrow)\b)?|"+ r"\bque dia es (?:hoy|manana)\b|\ba que fecha estamos\b"+)_FOLLOW_UP_REFERENCE_RE = re.compile(r"\b(?:that|there|those|them|inside|what else|findings?|results?|"@@ -417,10 +440,12 @@ def plan_turn()opinion = bool(_OPINION_RE.search(normalized))why_question = bool(_WHY_RE.search(normalized))- # Remove the assistant-dayplan idiom span so its own words ("machst",- # "morgen") cannot feed the weak action/current scans below.+ # Remove the assistant-dayplan and calendar-trivia idiom spans so their+ # own words ("machst", "morgen", "tomorrow") cannot feed the weak+ # action/current scans below.# i18n-allow: names the German idiom tokens under suppressionweak_scan_text = _ASSISTANT_DAYPLAN_RE.sub(" ", normalized)+ weak_scan_text = _DATE_TRIVIA_RE.sub(" ", weak_scan_text)action_intent = bool(_ACTION_FALLBACK_RE.search(weak_scan_text))if capability_registry is not None:@@ -432,7 +457,10 @@ def plan_turn(passlookup = bool(_LOOKUP_SHAPE_RE.search(normalized))- private = bool(_OWNERSHIP_RE.search(normalized))+ # Ownership scans the idiom-stripped text: the only possessive-shaped+ # token inside a stripped span is the "haben wir" of "Welches Datum+ # haben wir?" — calendar trivia, not the user's data. # i18n-allow+ private = bool(_OWNERSHIP_RE.search(weak_scan_text))if action_intent and not instructional and not (deliberative or opinion):reasons.add(TurnReason.ACTION)diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.pyindex 1757a02501..3268dec41a 100644--- a/jarvis/realtime/session.py+++ b/jarvis/realtime/session.py@@ -16,6 +16,7 @@ import randomimport reimport timefrom dataclasses import dataclass, field+from datetime import datetimefrom typing import Anyfrom uuid import uuid4@@ -63,9 +64,6 @@ _MAX_UNSCRUBBED_AUDIO_MS = 15_000_PROVIDER_HANDSHAKE_TOTAL_TIMEOUT_S = 12.0_AUDIO_SEND_TIMEOUT_S = 2.0_TOOL_TRANSCRIPT_WAIT_S = 3.0-_THINKING_PAUSE_DEFAULT_MS = 1_500-_THINKING_PAUSE_MIN_MS = 500-_THINKING_PAUSE_MAX_MS = 5_000# Grace window for the model to finish its goodbye after an end_call tool# call; if the provider never sends turn_complete, hang up anyway._END_CALL_GRACE_S = 10.0@@ -353,20 +351,6 @@ def _requires_jarvis_action(text: str) -> bool:return plan_turn(text).requires_orchestrator-def _configured_thinking_pause_ms(config: Any) -> int:- """Return the validated shared Pipeline/Realtime silence window."""- raw = getattr(- getattr(config, "speech", None),- "vad_silence_ms",- _THINKING_PAUSE_DEFAULT_MS,- )- try:- value = int(raw)- except (TypeError, ValueError):- value = _THINKING_PAUSE_DEFAULT_MS- return max(_THINKING_PAUSE_MIN_MS, min(_THINKING_PAUSE_MAX_MS, value))--def _delegate_result_prompt(text: str,*,@@ -628,6 +612,18 @@ def _session_instructions(from jarvis.brain.persona_loader import load_effective_persona_promptpersona = load_effective_persona_prompt().strip()+ # The block is re-sent with every per-turn session update, so this stays+ # current across long sessions. Without it the model must either+ # hallucinate calendar answers or delegate a trivial "what day is+ # tomorrow" through the orchestrator (12-34 s of silence — live+ # complaint 2026-07-21); the shared turn planner keeps such calendar+ # trivia native on the strength of this line.+ now = datetime.now().astimezone()+ clock_line = (+ f"Current local date and time: {now.strftime('%A, %Y-%m-%d %H:%M')} "+ f"({now.tzname() or 'local time'}). Answer date, weekday, and "+ "time-of-day questions directly from this — never guess."+ )language_name = _LANGUAGE_NAMES.get(language, "the user's language")input_language_name = _LANGUAGE_NAMES.get(input_language)if input_language_name:@@ -660,6 +656,7 @@ def _session_instructions(tool_directive,_REALTIME_SAFETY_APPENDIX,input_directive,+ clock_line,("Runtime identity: this voice session is using the Realtime engine"+ (f", provider {provider}" if provider else "")@@ -1098,7 +1095,10 @@ class RealtimeVoiceSession:input_sample_rate=input_rate,output_sample_rate=output_rate,modalities=("audio",),- silence_duration_ms=_configured_thinking_pause_ms(self._config),+ # silence_duration_ms stays at its None default: the realtime+ # model's native turn detection decides when the user is done.+ # The Settings "Thinking pause" endpoints the classic pipeline+ # only (maintainer directive 2026-07-21).tools=self._declared_tools(),# Empty at the first open of a call; after an in-place# transport rebuild (or a mid-call cross-family fallback) itdiff --git a/tests/unit/brain/test_provider_down_phrase.py b/tests/unit/brain/test_provider_down_phrase.pyindex a9313a556c..7ba0785307 100644--- a/tests/unit/brain/test_provider_down_phrase.py+++ b/tests/unit/brain/test_provider_down_phrase.py@@ -87,3 +87,90 @@ class TestNextProviderDownPhraseAutoDetect:def test_pin_wins_over_detected_turn_language(self) -> None:m = self._manager("de", "en")assert m._next_provider_down_phrase() == _PROVIDER_DOWN_PHRASES["de"][0]+++class TestCauseAwareProviderDownPhrase:+ """Maintainer directive 2026-07-21: when the chain fails, SAY what it was+ about — a classified root cause (missing key, dead credit, rate limit, ...)+ speaks its own honest, in-app-actionable sentence instead of the generic+ apology. Still voice-safe: no provider names, no URLs, no billing pages.+ """++ # Provider names and URL/billing jargon stay banned even in cause+ # phrases; naming the CAUSE ("credit used up") is the whole point, so+ # "credit"/"Guthaben" are deliberately allowed here. # i18n-allow+ _CAUSE_JARGON = (+ "grok", "anthropic", "openai", "openrouter", "gemini", "xai",+ "console.", "http", "billing",+ )++ def test_every_cause_covers_every_supported_language(self) -> None:+ from jarvis.brain.manager import _PROVIDER_DOWN_CAUSE_PHRASES++ for cause, table in _PROVIDER_DOWN_CAUSE_PHRASES.items():+ assert set(table) == {"de", "en", "es"}, cause++ def test_cause_phrases_are_voice_safe(self) -> None:+ from jarvis.brain.manager import _PROVIDER_DOWN_CAUSE_PHRASES++ for cause, table in _PROVIDER_DOWN_CAUSE_PHRASES.items():+ for lang, phrase in table.items():+ low = phrase.lower()+ for bad in self._CAUSE_JARGON:+ assert bad not in low, (cause, lang, bad)++ def test_known_cause_selects_cause_phrase(self) -> None:+ from jarvis.brain.manager import _PROVIDER_DOWN_CAUSE_PHRASES++ got = _provider_down_phrase("en", 0, "missing_key")+ assert got == _PROVIDER_DOWN_CAUSE_PHRASES["missing_key"]["en"]++ def test_unknown_cause_falls_back_to_generic_rotation(self) -> None:+ assert _provider_down_phrase("en", 1, "weird_kind") == (+ _PROVIDER_DOWN_PHRASES["en"][1]+ )++ def test_unknown_language_falls_back_to_german_cause_phrase(self) -> None:+ from jarvis.brain.manager import _PROVIDER_DOWN_CAUSE_PHRASES++ got = _provider_down_phrase("fr", 0, "rate_limit")+ assert got == _PROVIDER_DOWN_CAUSE_PHRASES["rate_limit"]["de"]+++class TestPrimaryProviderDownCause:+ @staticmethod+ def _err(kind: str, prov: str = "p") -> tuple[str, str, str, str]:+ return (prov, "model", kind, "detail")++ def test_missing_key_beats_rate_limit(self) -> None:+ from jarvis.brain.manager import _primary_provider_down_cause++ errors = [self._err("rate_limit", "a"), self._err("missing_key", "b")]+ assert _primary_provider_down_cause(errors) == "missing_key"++ def test_skipped_cooldown_reads_as_rate_limit(self) -> None:+ from jarvis.brain.manager import _primary_provider_down_cause++ assert (+ _primary_provider_down_cause([self._err("skipped_cooldown")])+ == "rate_limit"+ )++ def test_unclassified_failure_reads_as_unreachable(self) -> None:+ from jarvis.brain.manager import _primary_provider_down_cause++ assert (+ _primary_provider_down_cause([self._err("network_error")])+ == "unreachable"+ )++ def test_empty_response_only_keeps_generic_phrase(self) -> None:+ from jarvis.brain.manager import _primary_provider_down_cause++ assert _primary_provider_down_cause([self._err("empty_response")]) is None++ def test_no_errors_keeps_generic_phrase(self) -> None:+ from jarvis.brain.manager import _primary_provider_down_cause++ assert _primary_provider_down_cause([]) is None+ assert _primary_provider_down_cause(None) is Nonediff --git a/tests/unit/brain/test_turn_planner.py b/tests/unit/brain/test_turn_planner.pyindex 222c53af2b..4767447b7f 100644--- a/tests/unit/brain/test_turn_planner.py+++ b/tests/unit/brain/test_turn_planner.py@@ -402,3 +402,45 @@ def test_capability_canonical_utterances_route_to_orchestrator(utterance: str,) -> None:assert plan_turn(utterance).path is TurnPath.ORCHESTRATOR+++ "utterance",+ [+ # Live complaint 2026-07-21: calendar trivia ("Was ist morgen für # i18n-allow+ # ein Tag?") was force-delegated twice — 12-34 s of silence for a+ # question the realtime model answers itself from the current-date+ # line in its session instructions. Includes the real ASR garble+ # ("What is tomorrow for day?") from the live transcript.+ "Was ist morgen für ein Tag?", # i18n-allow: forensic fixture+ "Was ist heute für ein Datum?", # i18n-allow: forensic fixture+ "Welcher Tag ist morgen?", # i18n-allow: German speech-input fixture+ "Welcher Wochentag ist heute?", # i18n-allow: German fixture+ "Welches Datum haben wir?", # i18n-allow: German speech-input fixture+ "Der Wievielte ist heute?", # i18n-allow: German speech-input fixture+ "What day is it today?",+ "What day is tomorrow?",+ "What is tomorrow for day?",+ "What's the date?",+ "¿Qué día es hoy?",+ ],+)+def test_calendar_trivia_stays_native(utterance: str) -> None:+ assert plan_turn(utterance).path is TurnPath.NATIVE_REALTIME+++ "utterance",+ [+ # Counter-proofs: a time word next to REAL evidence keeps delegating —+ # weather/news are current data, a planned day is the user's calendar,+ # and a dated meeting lookup still needs connected evidence.+ "Wie ist das Wetter morgen?", # i18n-allow: German speech-input fixture+ "Was ist morgen geplant?", # i18n-allow: German speech-input fixture+ "Was steht heute in den Nachrichten?", # i18n-allow: German fixture+ "What's the date of my meeting tomorrow?",+ "What's in the news today?",+ ],+)+def test_time_words_with_real_evidence_still_delegate(utterance: str) -> None:+ assert plan_turn(utterance).path is TurnPath.ORCHESTRATOR