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): retry failed dictation warmups without retiring cold workers
rubenluetke10-beep035c92307e55
diff --git a/jarvis/dictation/local_final.py b/jarvis/dictation/local_final.pyindex aa3d04c3b3..4c13982e0f 100644--- a/jarvis/dictation/local_final.py+++ b/jarvis/dictation/local_final.py@@ -235,6 +235,10 @@ class LocalFinalSTT:f"the dictation worker takes 16 kHz audio, not {sample_rate} Hz")if not self._call_lock.acquire(blocking=False):+ if self.is_loading:+ raise LocalEngineUnavailable(+ "the local dictation engine is still starting"+ )await asyncio.to_thread(self.recover)raise LocalEngineUnavailable("a previous call is still waiting on the dictation worker; "diff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.pyindex ce248bd7cb..b58543e53d 100644--- a/jarvis/speech/pipeline.py+++ b/jarvis/speech/pipeline.py@@ -11217,6 +11217,11 @@ class SpeechPipeline:except Exception as exc: # noqa: BLE001 — lazy final STT still gets a chancelog.warning("Dictation STT warm-up failed; using lazy load: %s", exc)else:+ if not getattr(provider, "is_warm", True):+ log.info(+ "Dictation STT warm-up ended without a ready engine; retry remains enabled."+ )+ returnself._dictation_warmup_succeeded_provider = providerlog.info("Dictation STT warm-up done in %.0f ms.",@@ -11234,7 +11239,10 @@ class SpeechPipeline:provider = provider if provider is not None else self._dictation_stt()if provider is None or not callable(getattr(provider, "warm_up", None)):return- if getattr(self, "_dictation_warmup_succeeded_provider", None) is provider:+ if (+ getattr(self, "_dictation_warmup_succeeded_provider", None) is provider+ and getattr(provider, "is_warm", True)+ ):returncurrent = getattr(self, "_dictation_warmup_task", None)current_provider = getattr(self, "_dictation_warmup_provider", None)diff --git a/tests/unit/dictation/test_warmup_retry_readiness.py b/tests/unit/dictation/test_warmup_retry_readiness.pynew file mode 100644index 0000000000..d8cb5c087a--- /dev/null+++ b/tests/unit/dictation/test_warmup_retry_readiness.py@@ -0,0 +1,88 @@+"""Failed or retired native engines must re-enter the patient warm-up path."""++import asyncio+import threading++import pytest++from jarvis.dictation.local_final import LocalEngineUnavailable, LocalFinalSTT+from jarvis.speech.pipeline import SpeechPipeline+++class RecoveringProvider:+ def __init__(self):+ self.is_warm = False+ self.calls = 0++ def warm_up(self):+ self.calls += 1+ self.is_warm = self.calls > 1+++async def test_failed_warmup_is_retried_before_transcription():+ pipeline = SpeechPipeline.__new__(SpeechPipeline)+ provider = RecoveringProvider()+ pipeline._schedule_dictation_warmup(provider)+ await pipeline._join_dictation_warmup(provider)+ assert not provider.is_warm+ assert getattr(pipeline, "_dictation_warmup_succeeded_provider", None) is None++ pipeline._schedule_dictation_warmup(provider)+ await pipeline._join_dictation_warmup(provider)+ assert provider.is_warm+ assert provider.calls == 2+ pipeline._schedule_dictation_warmup(provider)+ await pipeline._join_dictation_warmup(provider)+ assert provider.calls == 2+++async def test_retired_engine_is_warmed_again_after_previous_success():+ pipeline = SpeechPipeline.__new__(SpeechPipeline)+ provider = RecoveringProvider()+ provider.calls = 1+ pipeline._schedule_dictation_warmup(provider)+ await pipeline._join_dictation_warmup(provider)+ assert provider.is_warm+ provider.is_warm = False+ pipeline._schedule_dictation_warmup(provider)+ await pipeline._join_dictation_warmup(provider)+ assert provider.is_warm+ assert provider.calls == 3+++async def test_second_press_during_abandoned_cold_load_does_not_kill_new_worker(monkeypatch):+ import jarvis.dictation.local_preview as preview++ started, release = threading.Event(), threading.Event()++ class Worker:+ device = "cpu"+ compute = "int8"+ closed = False++ def close(self):+ self.closed = True++ worker = Worker()++ def spawn(*args, **kwargs):+ started.set()+ assert release.wait(3)+ return worker++ monkeypatch.setattr(preview, "_spawn_worker_model", spawn)+ monkeypatch.setattr(preview, "faster_whisper_available", lambda: True)+ provider = LocalFinalSTT(allow_cpu=True)+ # The first press was cancelled while its native build kept running.+ provider._call_lock.acquire()+ warm = asyncio.create_task(asyncio.to_thread(provider.warm_up))+ try:+ assert await asyncio.to_thread(started.wait, 2)+ with pytest.raises(LocalEngineUnavailable, match="still starting"):+ await asyncio.wait_for(provider.transcribe_pcm(b"\0\0"), timeout=0.2)+ finally:+ release.set()+ await warm+ provider._call_lock.release()+ assert provider.is_warm+ assert not worker.closed