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
chore: auto-save WIP via Claude stop-hook safety net (2026-06-30 12:48)
Ruben Lütke395fdbefdeee
diff --git a/tests/unit/speech/test_phrase_language.py b/tests/unit/speech/test_phrase_language.pyindex 1bba6ede9b..42db5ffcf8 100644--- a/tests/unit/speech/test_phrase_language.py+++ b/tests/unit/speech/test_phrase_language.py@@ -24,10 +24,11 @@ import pytestfrom jarvis.speech import pipeline as pipeline_modfrom jarvis.speech.pipeline import (_ACTION_DONE_PHRASE,- _BRAIN_TIMEOUT_PHRASE,_BRAIN_UNAVAILABLE_PHRASE,_CLARIFY_QUESTION_PHRASE,_STT_UNAVAILABLE_PHRASE,+ _TIMEOUT_NO_ANSWER_PHRASE,+ _TIMEOUT_TOOL_STALL_PHRASE,SpeechPipeline,TurnTakingState,_smalltalk_fallback_for_non_substantive,@@ -114,7 +115,8 @@ def test_all_canned_phrase_tables_cover_de_en_es() -> None:for table in (_BRAIN_UNAVAILABLE_PHRASE,_STT_UNAVAILABLE_PHRASE,- _BRAIN_TIMEOUT_PHRASE,+ _TIMEOUT_TOOL_STALL_PHRASE,+ _TIMEOUT_NO_ANSWER_PHRASE,_CLARIFY_QUESTION_PHRASE,_ACTION_DONE_PHRASE,):@@ -153,9 +155,12 @@ async def test_action_done_ack_is_german_for_whisper_language_name() -> None:@pytest.mark.asyncioasync def test_brain_timeout_phrase_is_german_for_whisper_language_name() -> None:+ # A bare brain timeout with no tool evidence honestly admits "couldn't find+ # that out" — and resolves the Whisper language NAME "german" to the German+ # phrase, not the English fallback (the 2026-06-09 regression class).pipe = _make_pipe()await pipe._speak_brain_timeout("german")- assert pipe._spoken == [(_BRAIN_TIMEOUT_PHRASE["de"], "de")], pipe._spoken+ assert pipe._spoken == [(_TIMEOUT_NO_ANSWER_PHRASE["de"], "de")], pipe._spokendef test_smalltalk_fallback_is_german_for_whisper_language_name() -> None:diff --git a/tests/unit/speech/test_speak_playback_timeout.py b/tests/unit/speech/test_speak_playback_timeout.pyindex 1b717bc003..7ab6c55e47 100644--- a/tests/unit/speech/test_speak_playback_timeout.py+++ b/tests/unit/speech/test_speak_playback_timeout.py@@ -533,7 +533,7 @@ async def test_floor_guard_skipped_when_turn_anchor_unset() -> None:await p._handle_silent_brain_turn("de", "")- assert spoken == [_BRAIN_TIMEOUT_PHRASE["de"]], (+ assert spoken == [_TIMEOUT_TOOL_STALL_PHRASE["de"]], ("with no turn anchor the guard must default to speaking")@@ -591,7 +591,7 @@ async def test_no_first_frame_abort_at_ceiling_speaks_despite_brain_stall_floor(await p._handle_silent_brain_turn("de", "")- assert spoken == [_BRAIN_TIMEOUT_PHRASE["de"]], (+ assert spoken == [_TIMEOUT_TOOL_STALL_PHRASE["de"]], ("a genuine 20 s no-first-frame abort must speak, not be swallowed by the ""30 s brain-stall floor (the 2026-06-14 silent-research bug)")@@ -873,3 +873,196 @@ async def test_await_playback_still_aborts_genuine_midplayback_wedge() -> None:finally:if not play_task.done():play_task.cancel()+++# ---------------------------------------------------------------------------+# Honest, cause-aware timeout messaging (live complaint 2026-06-30).+#+# A voice turn called a slow MCP tool, hung ~35 s, then timed out — and Jarvis+# spoke a GENERIC, unhelpful "I couldn't finish the answer in time", giving the+# user NO reason. The fix replaces the one flat phrase with cause-aware+# messaging resolved through the SAME output-language decision (``_phrase_lang``):+# • a turn beheaded mid-tool-loop (no first audio frame), OR with a desktop+# (computer_use) tool demonstrably active, names an HONEST tool cause+# ("a tool I was waiting on didn't respond");+# • a bare provider stall / total cap with no tool evidence honestly admits it+# could not find the answer ("I couldn't find that out") — never the vague+# "took too long".+# String-only, no LLM call in this path (AP-11). All three locales (de/en/es).+# ---------------------------------------------------------------------------+++async def test_no_first_frame_timeout_speaks_honest_tool_cause() -> None:+ """A tool-stall / no-first-frame timeout must name an HONEST cause (a tool+ didn't respond), never an empty string, never the old vague wording.++ Reproduces the 2026-06-30 complaint: a NotebookLM MCP tool hung ~35 s and+ the turn was beheaded by the no-first-frame ceiling. The notice must explain+ WHY, not just apologise for "taking too long"."""+ p, spoken = _silent_turn_pipeline(flag=True, elapsed_s=20.83, floor=30.0)++ await p._handle_silent_brain_turn("de", "")++ assert spoken == [_TIMEOUT_TOOL_STALL_PHRASE["de"]]+ assert spoken[0], "the timeout notice must never be an empty string"+ assert "Tool" in spoken[0], "must name the honest cause (a tool didn't respond)"+++async def test_bare_provider_stall_admits_no_answer_honestly() -> None:+ """A bare provider stall with NO tool evidence must honestly admit it could+ not find the answer — not falsely blame a tool, not the vague 'took too+ long'."""+ p, spoken = _silent_turn_pipeline(flag=False, elapsed_s=45.0, floor=30.0)++ await p._speak_brain_timeout("de", site="stream_stall")++ assert spoken == [_TIMEOUT_NO_ANSWER_PHRASE["de"]]+ assert spoken[0], "the no-answer notice must never be an empty string"+++async def test_cu_tool_stall_names_tool_cause_even_on_stream_stall() -> None:+ """When a desktop (computer_use) tool was demonstrably active this turn, even+ a stream-stall timeout must name the tool cause, not the generic no-answer+ phrase — the tool was the thing we were waiting on."""+ p, spoken = _silent_turn_pipeline(flag=False, elapsed_s=45.0, floor=30.0)+ p._long_tool_last_activity = time.monotonic() # type: ignore[attr-defined]++ await p._speak_brain_timeout("de", site="stream_stall")++ assert spoken == [_TIMEOUT_TOOL_STALL_PHRASE["de"]]+++async def test_timeout_phrase_resolves_in_input_language() -> None:+ """The cause-aware notice resolves through the one output-language decision:+ a German turn gets the German phrase, an English turn the English one, a+ Spanish turn the Spanish one — never a wrong-language fallback."""+ for lang, table in (+ ("de", _TIMEOUT_TOOL_STALL_PHRASE),+ ("english", _TIMEOUT_TOOL_STALL_PHRASE),+ ("spanish", _TIMEOUT_TOOL_STALL_PHRASE),+ ):+ p, spoken = _silent_turn_pipeline(flag=True, elapsed_s=20.83, floor=30.0)+ await p._handle_silent_brain_turn(lang, "")+ expected_key = {"de": "de", "english": "en", "spanish": "es"}[lang]+ assert spoken == [table[expected_key]], (lang, spoken)+++def test_cause_aware_timeout_tables_cover_de_en_es() -> None:+ """Both new cause-aware tables must carry every supported locale (CLAUDE.md+ §1): an es speaker must never fall back to the wrong language."""+ for table in (_TIMEOUT_TOOL_STALL_PHRASE, _TIMEOUT_NO_ANSWER_PHRASE):+ assert {"de", "en", "es"} <= set(table), table+ for value in table.values():+ assert value and value.strip(), table+++# ---------------------------------------------------------------------------+# Double-answer guard (live complaint 2026-06-30): a turn that already spoke a+# timeout / "couldn't finish" notice must NOT then speak a SECOND brain answer+# for the same content. Once the timeout outcome is committed it is terminal for+# that utterance; a separately-spawned background mission readback+# (COMPLETION/SUBAGENT) is a DIFFERENT, legitimate path and is NOT gated. The+# flag re-arms at the next utterance.+# ---------------------------------------------------------------------------+++@dataclass+class CompletingPlayer:+ """A player whose ``play_chunks`` drains the (empty) stream and returns at+ once — models a normal, healthy short playback so ``_speak`` completes fast."""++ last_write_ns: int = 0+ stop_calls: int = 0++ async def play_chunks(self, chunks: AsyncIterator[AudioChunk]) -> None:+ async for _ in chunks:+ pass++ def stop(self) -> None:+ self.stop_calls += 1+++def _speak_pipeline() -> tuple[SpeechPipeline, FakeTTS]:+ bus = EventBus()+ tts = FakeTTS()+ pipeline = SpeechPipeline(tts=tts, bus=bus, enable_whisper_wake=False)+ pipeline._player = CompletingPlayer() # type: ignore[assignment]++ async def _no_barge() -> bool:+ return False++ pipeline._barge_monitor = _no_barge # type: ignore[assignment,method-assign]+ return pipeline, tts+++async def test_brain_answer_suppressed_after_timeout_spoken_same_turn() -> None:+ """A late/abandoned brain ANSWER (kind="reply") must be suppressed once a+ timeout notice has closed this turn — no double-answer for the same content."""+ pipeline, tts = _speak_pipeline()+ pipeline._brain_timeout_spoken_this_turn = True # type: ignore[attr-defined]++ barged = await asyncio.wait_for(+ pipeline._speak("Here is the real answer.", language="en"), timeout=5.0+ )++ assert barged is False+ assert tts.calls == [], (+ "a second brain answer must not be synthesized after a timeout notice"+ )+++async def test_brain_answer_speaks_normally_without_prior_timeout() -> None:+ """Counter-test: with no timeout spoken this turn (the flag re-armed), the+ ordinary brain answer speaks normally — the guard only muzzles a SECOND+ answer, never the first."""+ pipeline, tts = _speak_pipeline()+ pipeline._brain_timeout_spoken_this_turn = False # type: ignore[attr-defined]++ barged = await asyncio.wait_for(+ pipeline._speak("Here is the answer.", language="en"), timeout=5.0+ )++ assert barged is False+ assert len(tts.calls) == 1+ assert tts.calls[0][0] == "Here is the answer."+++async def test_background_readback_not_suppressed_by_timeout_flag() -> None:+ """A background mission readback (COMPLETION) is a DIFFERENT, legitimate turn+ and must speak even after a timeout closed an earlier utterance — the guard+ gates only the ordinary brain answer (kind="reply")."""+ pipeline, tts = _speak_pipeline()+ pipeline._brain_timeout_spoken_this_turn = True # type: ignore[attr-defined]++ await asyncio.wait_for(+ pipeline._speak(+ "Mission done.", language="en", kind=SPOKEN_KIND_COMPLETION+ ),+ timeout=5.0,+ )++ assert len(tts.calls) == 1, "a background readback must not be gated"+ assert tts.calls[0][0] == "Mission done."+++async def test_speak_brain_timeout_sets_terminal_flag() -> None:+ """Speaking the timeout notice marks the turn terminal so the double-answer+ guard engages; a turn whose phrase was floor-suppressed must NOT set it (no+ answer was actually spoken, so a real answer that follows must still play)."""+ p, spoken = _silent_turn_pipeline(flag=True, elapsed_s=20.83, floor=30.0)+ await p._speak_brain_timeout("de", site="empty_after_no_first_frame")+ assert p._brain_timeout_spoken_this_turn is True+ assert spoken, "sanity: this turn actually spoke the notice"++ p2, spoken2 = _silent_turn_pipeline(flag=False, elapsed_s=0.1, floor=30.0)+ await p2._speak_brain_timeout("de", site="stream_stall") # sub-floor → suppressed+ assert spoken2 == [], "sanity: floor guard suppressed the phrase"+ assert getattr(p2, "_brain_timeout_spoken_this_turn", False) is Falsediff --git a/tests/unit/speech/test_turn_taking.py b/tests/unit/speech/test_turn_taking.pyindex 991e87537b..b96a1b3c0a 100644--- a/tests/unit/speech/test_turn_taking.py+++ b/tests/unit/speech/test_turn_taking.py@@ -9,7 +9,8 @@ from jarvis.core.bus import EventBusfrom jarvis.core.events import TranscriptFinal, TranscriptionUpdatefrom jarvis.core.protocols import AudioChunk, Transcriptfrom jarvis.speech.pipeline import (- _BRAIN_TIMEOUT_PHRASE,+ _TIMEOUT_NO_ANSWER_PHRASE,+ _TIMEOUT_TOOL_STALL_PHRASE,SpeechPipeline,TurnTakingState,)@@ -436,8 +437,10 @@ async def test_brain_call_timeout_returns_to_listening_without_hanging() -> None# actual phrase table (not a hardcoded word) so a future reword of the# timeout phrase can't silently re-break this contract test.assert pipe._spoken, "brain timeout stayed silent (AD-OE6 violation)"- assert pipe._spoken[0][0] in _BRAIN_TIMEOUT_PHRASE.values(), (- f"expected a brain-timeout fallback phrase, got {pipe._spoken[0][0]!r}"+ # A bare provider stall (non-stream total cap, no tool evidence) honestly+ # admits it couldn't find the answer — not the vague "took too long".+ assert pipe._spoken[0][0] in _TIMEOUT_NO_ANSWER_PHRASE.values(), (+ f"expected a no-answer timeout fallback phrase, got {pipe._spoken[0][0]!r}")