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.

fix(voice): make the Thinking-pause slider govern the silence window

Ruben Lütkef76864401e08
diff --git a/jarvis/audio/vad.py b/jarvis/audio/vad.py
index bc3b55dddb..82189d9113 100644
--- a/jarvis/audio/vad.py
+++ b/jarvis/audio/vad.py
@@ -29,6 +29,16 @@ from jarvis.core.protocols import AudioChunk
VAD_SAMPLE_RATE = 16_000
VAD_FRAME_SAMPLES = 512 # fixed requirement from Silero
+# Upper bound on the adaptive patience grant, expressed as a multiple of the
+# user-configured base silence window. A long dictation / delegation widens the
+# silence window so a thinking pause is not cut, but the grant must never stretch
+# the window to a fixed absolute value that ignores the slider: a deliberately
+# short "thinking pause" (e.g. 1.0 s) was being silently forced to ~3 s, so the
+# turn never submitted near the configured threshold. At the 1.5 s default this
+# is a no-op (2 x 1.5 s == the historical fixed 3 s grant). See
+# tests/unit/audio/test_vad_turn_taking.py (stuck-in-LISTENING regression).
+_PATIENCE_FACTOR = 2
+
log = logging.getLogger("jarvis.audio.vad")
@@ -145,6 +155,12 @@ class SileroEndpointer:
endpoint is made more patient.
"""
want_frames = max(1, int(total_ms) // 32)
+ # Cap the grant relative to the configured base so the slider keeps
+ # governing the wait: the window may at most grow to _PATIENCE_FACTOR x
+ # the base, never to a fixed absolute value that overrides a short
+ # setting (the 1.0 s "Thinking pause" stuck-in-LISTENING bug, 2026-06-29).
+ # No-op at the 1.5 s default (2 x 1.5 s >= the 3 s callers request).
+ want_frames = min(want_frames, self._silence_frames * _PATIENCE_FACTOR)
extra = max(0, want_frames - self._silence_frames)
if extra > self._extra_silence_frames:
self._extra_silence_frames = extra
diff --git a/tests/unit/audio/test_vad_turn_taking.py b/tests/unit/audio/test_vad_turn_taking.py
index 1facbe9c5f..c995f10eaf 100644
--- a/tests/unit/audio/test_vad_turn_taking.py
+++ b/tests/unit/audio/test_vad_turn_taking.py
@@ -924,3 +924,112 @@ async def test_autonomous_patience_grant_resets_across_utterances() -> None:
f"got {len(utterances)} utterances; the second should have ended at the "
"10-frame base window, not the 93-frame extended window"
)
+
+
+# --------------------------------------------------------------------------- #
+# The configured "Thinking pause" must govern the silence window — stuck-in-
+# LISTENING regression (2026-06-29).
+#
+# Forensic: the user set the Settings slider to 1.0 s, expecting the turn to
+# submit after ~1 s of silence. It did not. The autonomous long-utterance grant
+# (and the STT-probe delegation grant) call ``extend_silence_window(3000)``,
+# which set the silence window to a FIXED 3000 ms regardless of the configured
+# base — so any utterance with >=2 s of speech waited ~3 s, and on pause-rich
+# speech the natural endpoint slipped so far that only the max_utterance cap
+# fired (forced-cut -> carry -> keep listening, NOT a submit) until the session
+# inactivity timeout ended it. The fix caps the grant relative to the configured
+# base, so the slider value actually governs the wait.
+# --------------------------------------------------------------------------- #
+
+
+async def test_configured_silence_window_submits_long_utterance_not_stuck() -> None:
+ """TEST A (the fix): with the slider at 1.0 s, a long utterance followed by
+ silence above the configured threshold must SUBMIT (yield exactly one
+ utterance) instead of hanging in LISTENING until the inactivity timeout.
+
+ 65 speech frames (> the 62-frame long-utterance trigger) arm the autonomous
+ patience grant; then 70 silence frames (2240 ms) follow. With the bug the
+ grant forces the window to a fixed ~3000 ms (93 frames), so 70 < 93 -> no
+ endpoint ever fires, the VAD never yields, and on the live ``_active_session``
+ loop the inactivity timeout would end the session. With the fix the grant is
+ capped relative to the 1.0 s base, so the window stays around 2 s and the
+ 70 silence frames cross it -> one submitted utterance.
+ """
+ vad = SileroEndpointer(silence_ms=1000) # production wiring: base 1.0 s
+ endpoint_reasons: list[str] = []
+ vad._on_endpoint = lambda reason: endpoint_reasons.append(reason) # type: ignore[method-assign]
+
+ probs = [0.9] * 65 + [0.0] * 70
+ _stub_vad(vad, probs)
+ frames = [_pcm_frame(0.08) for _ in range(65)] + [_pcm_frame(0.0) for _ in range(70)]
+
+ utterances = await _collect(vad, frames)
+
+ assert len(utterances) == 1, (
+ "a long utterance + 2.24 s of silence at a 1.0 s setting did not submit — "
+ "the hardcoded 3 s patience grant kept the turn stuck in LISTENING "
+ f"(endpoint reasons: {endpoint_reasons})"
+ )
+ assert endpoint_reasons == ["silence"], (
+ "the turn must end on the natural silence endpoint, not a forced cut "
+ f"(got {endpoint_reasons})"
+ )
+
+
+async def test_pure_silence_yields_nothing_so_session_idle_times_out() -> None:
+ """TEST B (regression): pure silence with NO captured speech must yield
+ nothing, so the session still ends via the inactivity timeout. The fix
+ (a shorter silence window) must not make noise/silence submit spuriously.
+
+ Mirrors the session-level guard ``test_idle_timeout_still_hangs_up_without_
+ inflight_mission``: a VAD that never yields -> ``_active_session`` returns
+ ``HANGUP_IDLE_TIMEOUT``.
+ """
+ vad = SileroEndpointer(silence_ms=1000)
+ probs = [0.0] * 120 # never crosses the speech threshold
+ _stub_vad(vad, probs)
+ frames = [_pcm_frame(0.0) for _ in range(120)]
+
+ utterances = await _collect(vad, frames)
+
+ assert utterances == [], (
+ "pure silence produced a submitted utterance — there was no captured "
+ "speech, so the session must fall through to the inactivity timeout"
+ )
+
+
+async def test_lower_thinking_pause_submits_sooner_than_higher() -> None:
+ """TEST C (config): the configured threshold must govern the timing. With
+ the SAME long utterance and the SAME amount of trailing silence, a lower
+ "Thinking pause" setting submits while a higher one is still waiting —
+ proving the slider value (not a fixed 3 s constant) drives the endpoint.
+
+ 75 silence frames (2400 ms) follow a long utterance for both VADs. With the
+ bug both windows are forced to a fixed ~3000 ms (93 frames), so 75 < 93 ->
+ NEITHER submits and the timing is identical regardless of the setting. With
+ the fix the 1.0 s base caps the window near 2 s (75 frames cross it -> submit)
+ while the 1.5 s base caps it near 3 s (75 frames do not -> still waiting).
+ """
+ async def _submitted(silence_ms: int) -> int:
+ vad = SileroEndpointer(silence_ms=silence_ms)
+ probs = [0.9] * 65 + [0.0] * 75
+ _stub_vad(vad, probs)
+ frames = [_pcm_frame(0.08) for _ in range(65)] + [
+ _pcm_frame(0.0) for _ in range(75)
+ ]
+ return len(await _collect(vad, frames))
+
+ submitted_at_1000ms = await _submitted(1000)
+ submitted_at_1500ms = await _submitted(1500)
+
+ assert submitted_at_1000ms == 1, (
+ "the 1.0 s setting did not submit after 2.4 s of silence — its window is "
+ "still pinned to the fixed 3 s grant instead of scaling with the setting"
+ )
+ assert submitted_at_1500ms == 0, (
+ "the 1.5 s setting submitted at the same silence as the 1.0 s one — the "
+ "endpoint timing does not scale with the configured threshold"
+ )