Skip to content

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.

test(voice): guard classic startup under CPU load

Ruben Lütke77c626a119ab
diff --git a/docs/BUGS.md b/docs/BUGS.md
index 896699e62c..19a48de1bb 100644
--- a/docs/BUGS.md
+++ b/docs/BUGS.md
@@ -3284,6 +3284,13 @@ still starts and completes. The existing
`test_capture_precedes_listening_signal_and_preserves_startup_audio` retain the
metering, ordering, and zero-loss guarantees.
+The classic pipeline does not have a session-builder step before VAD: it
+consumes the same capture-first buffer immediately. The companion
+`test_pipeline_mode_listens_with_default_thread_pool_exhausted` pins that this
+path still accepts the opening audio even when wake/local-STT work occupies
+every shared executor worker. Weak-CPU endpointing remains covered separately
+by `test_capture_overflow` and `test_vad_realtime_gap_credit`.
+
**Class rule.** A voice-critical recovery or startup control path must never
depend on the same executor used by un-cancellable native inference. Opening
the microphone early is necessary but not sufficient: every prerequisite for
diff --git a/tests/unit/speech/test_realtime_mode.py b/tests/unit/speech/test_realtime_mode.py
index 777a556d77..90e7b5ee4f 100644
--- a/tests/unit/speech/test_realtime_mode.py
+++ b/tests/unit/speech/test_realtime_mode.py
@@ -496,6 +496,41 @@ async def test_pipeline_mode_never_enters_realtime_branch(
assert await asyncio.wait_for(pipe._active_session(), timeout=2.0) == HANGUP_SHUTDOWN
+async def test_pipeline_mode_listens_with_default_thread_pool_exhausted() -> None:
+ """Classic VAD startup must not depend on workers used by wake or local STT."""
+ pipe = _pipe(mode="pipeline")
+ opening_pcm = b"\x00\x40" * 320
+ opening = AudioChunk(pcm=opening_pcm, sample_rate=16_000, timestamp_ns=1)
+ buffer = pipeline_mod._SessionInputBuffer(initial=(opening,)) # noqa: SLF001
+ buffer.finish()
+ captured: list[bytes] = []
+ pipe._vad = _OneShotVad(captured)
+ pipe._session_end_reason = HANGUP_TURN_COMPLETE
+
+ async def _handle(pcm: bytes) -> bool:
+ assert pcm == opening_pcm
+ return False
+
+ pipe._handle_utterance = _handle # type: ignore[method-assign]
+
+ loop = asyncio.get_running_loop()
+ release_pool = threading.Event()
+ blockers = [loop.run_in_executor(None, release_pool.wait) for _ in range(64)]
+ await asyncio.sleep(0.1)
+ try:
+ reason = await asyncio.wait_for(
+ pipe._active_session(input_buffer=buffer),
+ timeout=1.0,
+ )
+ finally:
+ release_pool.set()
+ await asyncio.gather(*blockers, return_exceptions=True)
+
+ assert reason == HANGUP_TURN_COMPLETE
+ assert captured == [opening_pcm]
+
+
def test_live_mode_change_schedules_active_call_for_reopen() -> None:
pipe = _pipe(mode="pipeline")
pipe._state = pipeline_mod.PipelineState.ACTIVE