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: apply thinking pause to realtime voice

Ruben Lütke57ae99694072
diff --git a/docs/superpowers/specs/2026-06-16-adjustable-silence-window-slider-design.md b/docs/superpowers/specs/2026-06-16-adjustable-silence-window-slider-design.md
index d94aba6484..fe9728ed92 100644
--- a/docs/superpowers/specs/2026-06-16-adjustable-silence-window-slider-design.md
+++ b/docs/superpowers/specs/2026-06-16-adjustable-silence-window-slider-design.md
@@ -36,6 +36,27 @@ chosen value must *actually take effect* — setting 5 s must make Jarvis wait 5
base because it reads `_silence_frames`).
- No wake-word VAD change (`whisper_wake.py` has its own short 500 ms window).
+## Realtime extension (2026-07-13)
+
+The same setting also owns the turn boundary for native Realtime voice. The
+provider-neutral `RealtimeSessionConfig.silence_duration_ms` receives
+`SpeechConfig.vad_silence_ms` whenever a browser or desktop Realtime session is
+opened, including every cross-family handshake fallback.
+
+- OpenAI Realtime sends the value as
+ `session.audio.input.turn_detection.silence_duration_ms` in `server_vad`
+ mode. Jarvis retains `create_response=false`, so the provider commits the
+ input only after the configured silence and Jarvis explicitly requests the
+ response after the final transcript.
+- Gemini Live sends the value as
+ `realtime_input_config.automatic_activity_detection.silence_duration_ms`.
+ Gemini therefore does not commit the automatic activity boundary or begin
+ its automatic response during a shorter mid-thought pause.
+
+The classic VAD still accepts an in-process live update. Jarvis configures the
+Realtime VAD during session setup, so a newly selected value governs the next
+Realtime connection; no application restart is required.
+
## Architecture
The feature is a single value threaded through a five-link chain. Two links
diff --git a/jarvis/plugins/realtime/gemini_live.py b/jarvis/plugins/realtime/gemini_live.py
index e480a3af01..240c7d5cb3 100644
--- a/jarvis/plugins/realtime/gemini_live.py
+++ b/jarvis/plugins/realtime/gemini_live.py
@@ -319,6 +319,14 @@ class GeminiLiveProvider:
system_instruction=str(getattr(cfg, "instructions", "") or "") or None,
input_audio_transcription=types.AudioTranscriptionConfig(),
output_audio_transcription=types.AudioTranscriptionConfig(),
+ realtime_input_config=types.RealtimeInputConfig(
+ automatic_activity_detection=types.AutomaticActivityDetection(
+ disabled=False,
+ silence_duration_ms=int(
+ getattr(cfg, "silence_duration_ms", 1_500) or 1_500
+ ),
+ )
+ ),
**(
{
"tools": [
diff --git a/jarvis/plugins/realtime/openai_realtime.py b/jarvis/plugins/realtime/openai_realtime.py
index aca3ceda90..a92c4af574 100644
--- a/jarvis/plugins/realtime/openai_realtime.py
+++ b/jarvis/plugins/realtime/openai_realtime.py
@@ -76,6 +76,20 @@ def _session_payload(cfg: Any) -> dict[str, Any]:
if voice:
output["voice"] = voice
+ turn_detection_config: dict[str, Any] = {
+ "type": turn_detection,
+ # Jarvis requests the response only after the final input transcript
+ # has passed the single turn-language resolver.
+ "create_response": False,
+ # Jarvis also owns barge-in explicitly. Keeping both flags false is
+ # OpenAI's documented manual-response VAD mode.
+ "interrupt_response": False,
+ }
+ if turn_detection == "server_vad":
+ turn_detection_config["silence_duration_ms"] = int(
+ getattr(cfg, "silence_duration_ms", 1_500) or 1_500
+ )
+
payload: dict[str, Any] = {
"type": "realtime",
"instructions": str(getattr(cfg, "instructions", "") or ""),
@@ -84,15 +98,7 @@ def _session_payload(cfg: Any) -> dict[str, Any]:
"input": {
"format": {"type": "audio/pcm", "rate": _INPUT_RATE},
"transcription": transcription,
- "turn_detection": {
- "type": turn_detection,
- # Jarvis requests the response only after the final input
- # transcript has passed the single turn-language resolver.
- "create_response": False,
- # Jarvis also owns barge-in explicitly. Keeping both flags
- # false is OpenAI's documented manual-response VAD mode.
- "interrupt_response": False,
- },
+ "turn_detection": turn_detection_config,
},
"output": output,
},
diff --git a/jarvis/realtime/protocol.py b/jarvis/realtime/protocol.py
index f4edecd285..eebdf6a310 100644
--- a/jarvis/realtime/protocol.py
+++ b/jarvis/realtime/protocol.py
@@ -58,6 +58,10 @@ class RealtimeSessionConfig:
# GA Realtime schema rejects requesting text and audio simultaneously.
modalities: tuple[str, ...] = ("audio",)
turn_detection: str = "server_vad" # "server_vad" | "semantic_vad"
+ # Shared with SpeechConfig.vad_silence_ms (the Settings "Thinking pause").
+ # Providers must wait for this much detected silence before committing the
+ # user's turn, so a natural pause cannot start model reasoning early.
+ silence_duration_ms: int = 1500
tools: tuple[dict[str, Any], ...] = ()
diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.py
index 642ba057ff..0a578a27a4 100644
--- a/jarvis/realtime/session.py
+++ b/jarvis/realtime/session.py
@@ -31,6 +31,9 @@ _MAX_UNSCRUBBED_AUDIO_MS = 5_000
_PROVIDER_HANDSHAKE_TOTAL_TIMEOUT_S = 12.0
_AUDIO_SEND_TIMEOUT_S = 2.0
_TOOL_TRANSCRIPT_WAIT_S = 3.0
+_THINKING_PAUSE_DEFAULT_MS = 1_500
+_THINKING_PAUSE_MIN_MS = 500
+_THINKING_PAUSE_MAX_MS = 5_000
# Grace window for the model to finish its goodbye after an end_call tool
# call; if the provider never sends turn_complete, hang up anyway.
_END_CALL_GRACE_S = 10.0
@@ -143,6 +146,20 @@ def _requires_jarvis_action(text: str) -> bool:
return plan_turn(text).requires_orchestrator
+def _configured_thinking_pause_ms(config: Any) -> int:
+ """Return the validated shared Pipeline/Realtime silence window."""
+ raw = getattr(
+ getattr(config, "speech", None),
+ "vad_silence_ms",
+ _THINKING_PAUSE_DEFAULT_MS,
+ )
+ try:
+ value = int(raw)
+ except (TypeError, ValueError):
+ value = _THINKING_PAUSE_DEFAULT_MS
+ return max(_THINKING_PAUSE_MIN_MS, min(_THINKING_PAUSE_MAX_MS, value))
+
+
def _delegate_result_prompt(
text: str,
*,
@@ -551,6 +568,7 @@ class RealtimeVoiceSession:
input_sample_rate=input_rate,
output_sample_rate=output_rate,
modalities=("audio",),
+ silence_duration_ms=_configured_thinking_pause_ms(self._config),
tools=self._declared_tools(),
)
try:
diff --git a/jarvis/ui/web/frontend/src/views/settings/SilenceWindowGroup.tsx b/jarvis/ui/web/frontend/src/views/settings/SilenceWindowGroup.tsx
index e6e583a51a..62e098aa49 100644
--- a/jarvis/ui/web/frontend/src/views/settings/SilenceWindowGroup.tsx
+++ b/jarvis/ui/web/frontend/src/views/settings/SilenceWindowGroup.tsx
@@ -9,8 +9,9 @@ import { useT } from "@/i18n";
* silence window (how long Jarvis waits in silence before submitting). Range
* 0.5–5.0 s, step 0.1 s, default 1.5 s. The label tracks the slider live; the
* PUT fires on release (pointer/key up) so a 0.1 s-step drag does not storm the
- * backend. The change persists to jarvis.toml and applies live to the running
- * pipeline — no restart (a headless host falls back to "applies on next start").
+ * backend. The change persists to jarvis.toml, applies live to the classic
+ * pipeline, and configures every newly opened Realtime provider session (a
+ * headless host falls back to "applies on next start").
*/
export function SilenceWindowGroup() {
const t = useT();
diff --git a/tests/unit/realtime/test_gemini_live.py b/tests/unit/realtime/test_gemini_live.py
index a8439a5af9..9731fdf52d 100644
--- a/tests/unit/realtime/test_gemini_live.py
+++ b/tests/unit/realtime/test_gemini_live.py
@@ -149,13 +149,21 @@ async def test_every_selectable_model_uses_live_audio_and_transcriptions(
provider = GeminiLiveProvider(api_key="test-key")
session = await provider.open_session(
- RealtimeSessionConfig(model=model, voice="Puck")
+ RealtimeSessionConfig(
+ model=model,
+ voice="Puck",
+ silence_duration_ms=2_700,
+ )
)
selected, config = holder["client"].aio.live.connect_calls[0]
assert selected == model
assert config.input_audio_transcription is not None
assert config.output_audio_transcription is not None
+ assert (
+ config.realtime_input_config.automatic_activity_detection.silence_duration_ms
+ == 2_700
+ )
assert config.speech_config.voice_config.prebuilt_voice_config.voice_name == "Puck"
await session.close()
assert holder["client"].closed is True
diff --git a/tests/unit/realtime/test_openai_realtime.py b/tests/unit/realtime/test_openai_realtime.py
index d18e9b99cd..7fe1af3f98 100644
--- a/tests/unit/realtime/test_openai_realtime.py
+++ b/tests/unit/realtime/test_openai_realtime.py
@@ -119,7 +119,12 @@ async def test_every_selectable_model_uses_the_valid_ga_session_schema(
provider = OpenAIRealtimeProvider(api_key="test-key")
session = await provider.open_session(
- RealtimeSessionConfig(model=model, voice="echo", language="en")
+ RealtimeSessionConfig(
+ model=model,
+ voice="echo",
+ language="en",
+ silence_duration_ms=2_700,
+ )
)
client = holder["client"]
payload = client.realtime.last_conn.session_updates[0]
@@ -141,6 +146,7 @@ async def test_every_selectable_model_uses_the_valid_ga_session_schema(
assert "language" not in payload["audio"]["input"]["transcription"]
assert payload["audio"]["input"]["turn_detection"]["create_response"] is False
assert payload["audio"]["input"]["turn_detection"]["interrupt_response"] is False
+ assert payload["audio"]["input"]["turn_detection"]["silence_duration_ms"] == 2_700
assert payload["audio"]["output"]["voice"] == "echo"
await session.request_response()
assert client.realtime.last_conn.response_creates == 1
diff --git a/tests/unit/realtime/test_protocol.py b/tests/unit/realtime/test_protocol.py
index be299fe1cf..29136f49f1 100644
--- a/tests/unit/realtime/test_protocol.py
+++ b/tests/unit/realtime/test_protocol.py
@@ -30,3 +30,12 @@ def test_session_config_has_selectable_model():
cfg = RealtimeSessionConfig(model="gpt-realtime-2.1", voice="echo")
assert cfg.model == "gpt-realtime-2.1"
assert cfg.voice == "echo"
+
+
+def test_session_config_defaults_to_shared_thinking_pause():
+ from jarvis.core.config import SpeechConfig
+ from jarvis.realtime.protocol import RealtimeSessionConfig
+
+ assert RealtimeSessionConfig().silence_duration_ms == (
+ SpeechConfig().vad_silence_ms
+ ) == 1_500
diff --git a/tests/unit/realtime/test_thinking_pause.py b/tests/unit/realtime/test_thinking_pause.py
new file mode 100644
index 0000000000..0553f2a208
--- /dev/null
+++ b/tests/unit/realtime/test_thinking_pause.py
@@ -0,0 +1,93 @@
+"""The Settings thinking pause must reach every realtime provider family."""
+
+from __future__ import annotations
+
+import asyncio
+from types import SimpleNamespace
+
+import pytest
+
+from jarvis.realtime.session import RealtimeVoiceSession
+
+
+class _Session:
+ session_id = "thinking-pause"
+ creates_responses_automatically = False
+ isolates_response_generations = True
+
+ async def send_audio(self, _chunk):
+ return None
+
+ async def receive(self):
+ if False:
+ yield None
+
+ async def update_session(self, **_kwargs):
+ return None
+
+ async def request_response(self, **_kwargs):
+ return None
+
+ async def send_text(self, _text):
+ return None
+
+ async def truncate(self, _audio_end_ms):
+ return None
+
+ async def interrupt(self):
+ return None
+
+ async def send_tool_result(self, _call_id, _name, _result):
+ return None
+
+ async def close(self):
+ return None
+
+
+class _Provider:
+ supports_realtime = True
+ input_sample_rate = 16_000
+ output_sample_rate = 24_000
+
+ def __init__(self, name: str, *, fail: bool = False) -> None:
+ self.name = name
+ self.fail = fail
+ self.opened_with = None
+
+ async def can_open_duplex_session(self):
+ return True
+
+ async def open_session(self, config):
+ self.opened_with = config
+ if self.fail:
+ raise RuntimeError("simulated provider outage")
+ return _Session()
+
+
+def _config(silence_ms: int):
+ return SimpleNamespace(
+ brain=SimpleNamespace(reply_language="en", providers={}),
+ speech=SimpleNamespace(vad_silence_ms=silence_ms),
+ stt=SimpleNamespace(language="auto"),
+ voice=SimpleNamespace(mode="realtime", realtime_tool_mode="delegate"),
+ latency=SimpleNamespace(enabled=False),
+ )
+
+
+async def test_configured_pause_reaches_primary_and_cross_family_fallback():
+ primary = _Provider("first-family", fail=True)
+ fallback = _Provider("second-family")
+ session = RealtimeVoiceSession(
+ session_id="thinking-pause",
+ send_binary=lambda _data: asyncio.sleep(0),
+ send_json=lambda _message: asyncio.sleep(0),
+ providers=[primary, fallback],
+ config=_config(2_700),
+ )
+
+ await session.handle_control({"type": "audio_start", "sample_rate": 16_000})
+
+ assert primary.opened_with.silence_duration_ms == 2_700
+ assert fallback.opened_with.silence_duration_ms == 2_700
+ await session.end(reason="test")