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:33)
Ruben Lütkea6017605e64d
diff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.pyindex 6e03d4fe3b..bc6c798f60 100644--- a/jarvis/speech/pipeline.py+++ b/jarvis/speech/pipeline.py@@ -6827,14 +6827,19 @@ class SpeechPipeline:stall_s = getattr(self, "_brain_timeout_s", 30.0)ceiling_s = getattr(self, "_brain_hard_timeout_s", 90.0)self._mark_brain_progress()- first_progress_floor = self._brain_last_progress# Each turn starts with the ceiling fully armed: only a computer_use# step THIS turn (ObservationCaptured/ActionPlanned → _on_agent_progress)# may suspend it — never a stale heartbeat bled over from a previous# desktop turn that finished moments ago.self._long_tool_last_activity = 0.0- # Reset the pre-first-token thinking heartbeat per turn (no stale bleed).+ # Reset per turn (no stale bleed): the still-working heartbeat AND the+ # "a speakable token has reached TTS" flag that gates it. The heartbeat+ # runs until the FIRST speakable token (_spoke_this_turn), so a stale+ # True bled over from the previous turn must not suppress it on this+ # turn's first poll (BUG-032 stale-counter class). _brain_streaming+ # also clears it, but the guard's poll loop can run first.self._brain_thinking_heartbeat = 0.0+ self._spoke_this_turn = Falsestart = time.monotonic()task: asyncio.Task[tuple[str, bool]] = asyncio.ensure_future(coro)monitor_task: asyncio.Task[bool] | None = None@@ -6930,19 +6935,32 @@ class SpeechPipeline:stalled = (not playback_active) and (now - self._brain_last_progress) >= stall_s- # Pre-first-token "still-thinking" heartbeat: while the brain has- # made NO progress yet (a token / tool round / CU step would have- # advanced _brain_last_progress past the initial guard mark), keep- # a dedicated heartbeat fresh so the no-first-frame TTS ceiling — which- # re-arms off it — does not behead a brain that is legitimately- # thinking (live bug 2026-06-14 16:17: Gemini built an 18k-token- # cache then thought ~17 s with no on_progress; the 20 s ceiling- # beheaded it, since_progress_s=20.19). It STOPS the instant real- # progress arrives (so a wedged TTS after a real token is still- # aborted) and is bounded by the absolute hard cap below (measured- # from `start`, never reset here) so a truly hung brain still dies.+ # "Still-working" heartbeat: until the brain hands its FIRST+ # speakable sentence to TTS (_spoke_this_turn), keep a dedicated+ # heartbeat fresh so the no-first-frame TTS ceiling — which+ # re-arms off it — cannot behead a brain that is still thinking+ # OR still in its tool loop. Two live bugs this must cover:+ # • 2026-06-14 16:17 (Gemini built an 18k-token cache then+ # thought ~17 s with no on_progress, since_progress_s=20.19):+ # PRE-first-token thinking emits no heartbeat of its own.+ # • 2026-06-30 ("München nach Bora Bora", since_progress_s=20.77):+ # the brain ran ONE tool round (~10 s in) then worked a second+ # ~20 s model roundtrip with no further ping and no token. The+ # old gate (_brain_last_progress <= first_progress_floor) froze+ # the heartbeat at that first round — so the 20 s ceiling+ # beheaded the turn 10 s before the 30 s brain stall guard+ # would have. A tool round is progress, but it is NOT a spoken+ # token: only _spoke_this_turn means TTS actually has text, so+ # only then may the no-first-frame ceiling judge a wedged+ # provider.+ # It STOPS the instant a speakable token reaches TTS (so a wedged+ # TTS after real output is still aborted) and is bounded by the+ # absolute hard cap below (measured from `start`, never reset here)+ # so a truly hung brain still dies. The independent no-progress+ # `stalled` check above is unaffected — a brain that pings nothing+ # for stall_s still times out on schedule.if (- self._brain_last_progress <= first_progress_floor+ not getattr(self, "_spoke_this_turn", False)and (now - start) < ceiling_s):self._brain_thinking_heartbeat = nowdiff --git a/tests/unit/speech/test_speak_playback_timeout.py b/tests/unit/speech/test_speak_playback_timeout.pyindex 5ab99c7140..833a7ab4e3 100644--- a/tests/unit/speech/test_speak_playback_timeout.py+++ b/tests/unit/speech/test_speak_playback_timeout.py@@ -632,10 +632,12 @@ def test_no_first_frame_phrase_floor_clamped_to_ceiling() -> None:# a working brain. Live bug 2026-06-14 16:17 (Berlin→Melbourne research):# Gemini built an 18k-token cache, thought silently ~17 s, ceiling fired# (since_progress_s=20.19). The stall guard pings a DEDICATED-# _brain_thinking_heartbeat while the brain is pre-first-token; the ceiling-# re-arm honours it. It must stop at first progress (so a wedged TTS after a-# real token is still aborted) and must NOT mask a hung brain (the 90 s hard-# cap, measured from turn start, still fires).+# _brain_thinking_heartbeat while the brain has not yet spoken; the ceiling+# re-arm honours it. It runs until the first SPEAKABLE token reaches TTS+# (_spoke_this_turn) — NOT merely the first tool round (live bug 2026-06-30:+# a tool round then a 20 s silent model roundtrip was beheaded mid-work) —+# then freezes so a wedged TTS after real output is still aborted, and it must+# NOT mask a hung brain (the 90 s hard cap, measured from turn start, still fires).# ---------------------------------------------------------------------------@@ -701,32 +703,33 @@ async def test_stall_guard_pings_thinking_heartbeat_pre_first_token() -> None:@pytest.mark.asyncio-async def test_thinking_heartbeat_stops_after_first_progress() -> None:- """Once the brain makes real progress (first token → _mark_brain_progress),- the dedicated thinking heartbeat must FREEZE: the real _brain_last_progress- signal governs from then on, so a brain that produces a token and then wedges- its TTS is still aborted by the no-first-frame ceiling (the thinking- heartbeat must not paper over a post-token wedge). RED before WS2."""+async def test_thinking_heartbeat_stops_after_first_spoken_token() -> None:+ """Once the brain hands its first SPEAKABLE sentence to TTS+ (``_spoke_this_turn``), the dedicated thinking heartbeat must FREEZE: from+ then on TTS genuinely has text, so a provider that yields no audio is a real+ wedge and the no-first-frame ceiling must be free to abort it (the heartbeat+ must not paper over a post-token wedge). A mere tool round must NOT freeze it+ (see test_thinking_heartbeat_survives_tool_round_until_first_spoken_token)."""bus = EventBus()pipeline = SpeechPipeline(tts=FakeTTS(), bus=bus, enable_whisper_wake=False)pipeline._brain_stall_poll_s = 0.02 # type: ignore[attr-defined]pipeline._brain_timeout_s = 10.0 # type: ignore[attr-defined]pipeline._brain_hard_timeout_s = 10.0 # type: ignore[attr-defined]- async def _think_then_progress() -> tuple[str, bool]:+ async def _think_then_speak() -> tuple[str, bool]:await asyncio.sleep(0.1) # pre-token thinking — heartbeat advancesassert getattr(pipeline, "_brain_thinking_heartbeat", 0.0) > 0.0- pipeline._mark_brain_progress() # first token arrives- await asyncio.sleep(0.08) # let the poll loop observe the progress+ pipeline._spoke_this_turn = True # first speakable sentence reaches TTS+ await asyncio.sleep(0.08) # let the poll loop observe the spoken flagfrozen = pipeline._brain_thinking_heartbeat # type: ignore[attr-defined]await asyncio.sleep(0.12) # post-token silenceassert pipeline._brain_thinking_heartbeat == frozen, ( # type: ignore[attr-defined]- "thinking heartbeat must freeze once real progress is seen"+ "thinking heartbeat must freeze once a speakable token reaches TTS")return ("done", False)result = await asyncio.wait_for(- pipeline._run_brain_with_stall_guard(_think_then_progress()), timeout=5.0+ pipeline._run_brain_with_stall_guard(_think_then_speak()), timeout=5.0)assert result == ("done", False)