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(realtime): free the microphone fast, and stop punishing a silent line
rubenluetke10-beep521852cf0c1a
diff --git a/jarvis/plugins/realtime/codex_subscription.py b/jarvis/plugins/realtime/codex_subscription.pyindex 7ac72e8959..0690fd1239 100644--- a/jarvis/plugins/realtime/codex_subscription.py+++ b/jarvis/plugins/realtime/codex_subscription.py@@ -42,6 +42,12 @@ _OUTPUT_QUIESCENCE_S = 1.2# final arriving mid-greeting ADOPTS the response instead (see the local# input branch), so a genuinely fast answer is never cut._OPENING_RESPONSE_MAX_S = 6.0+# Much tighter cap while the user is MID-UTTERANCE: under half-duplex the+# greeting's own playback mutes the microphone, so every second of overlap+# eats a second of the user's first question (live probe 2026-08-06: only+# 2.4 s of the question survived and the server answered a fragment). The+# model may say "hey", not a paragraph, over a speaking user.+_OPENING_OVERLAP_MAX_S = 2.0# How long after the last audible provider frame a further frame still counts# as the REST of the same answer rather than a new response.#@@ -757,6 +763,12 @@ class _CodexSubscriptionRealtimeSession:refusal_run_started_at = 0.0# Whether this run already logged that it stopped interrupting.refusal_storm_noted = False+ # One-shot marker for the silent-line variant of a refusal storm:+ # every response was refused before a frame ever played, so the+ # transport is fine and the gate is winning - a rebuild would only+ # buy a fresh greeting to refuse (and, via the relapse rule, could+ # end a call whose user is simply quiet; the no-idle-hangup mandate).+ silent_line_noted = False# Set by the refusal path once the run proves a loop; the receive loop# turns it into the user-facing reconnect advice on its next pass# (``_begin_response`` is not a generator and cannot yield).@@ -974,6 +986,7 @@ class _CodexSubscriptionRealtimeSession:nonlocal refusal_storm_noted, self_dialogue_detectednonlocal sequence_boundary_pendingnonlocal response_grant, call_response_index+ nonlocal silent_line_notedif response_open:if response_allowed or not _rejected_response_is_stale():return response_allowed@@ -1105,7 +1118,13 @@ class _CodexSubscriptionRealtimeSession:if (refusal_run >= _REFUSALS_BEFORE_REBUILDand not self_dialogue_detected+ and local_input_generation > 0):+ # The discriminator: somebody REALLY spoke on this+ # transport, so a storm now means the call went mute-broken+ # (BUG-124's 17:39 death) and a fresh transport is the way+ # out. A storm on a line nobody ever spoke into is just+ # the far end talking AT silence - handled below.self_dialogue_detected = Trueself._diag["self_dialogue_rebuilds"] += 1log.warning(@@ -1126,6 +1145,20 @@ class _CodexSubscriptionRealtimeSession:queue.put_nowait(("self_dialogue", None))except asyncio.QueueFull:pass+ elif (+ refusal_run >= _REFUSALS_BEFORE_REBUILD+ and not self_dialogue_detected+ and not silent_line_noted+ ):+ silent_line_noted = True+ log.info(+ "Codex subscription keeps refusing the far end's "+ "automatic responses on a silent line (%d so far); "+ "no refused frame was ever played, so the transport "+ "stays - a rebuild would only buy a fresh greeting "+ "to refuse",+ refusal_run,+ )if response_allowed:# An authorized response proves there is no loop: whatever the# run was counting ended here.@@ -1675,7 +1708,12 @@ class _CodexSubscriptionRealtimeSession:opening_age = (asyncio.get_running_loop().time() - first_audible_at)- if opening_age > _OPENING_RESPONSE_MAX_S:+ opening_cap = (+ _OPENING_OVERLAP_MAX_S+ if user_utterance_open+ else _OPENING_RESPONSE_MAX_S+ )+ if opening_age > opening_cap:# No user question exists yet and the opener is# still going: this is the 13.9 s / 16 s demo# monologue class, cut at the cap. A greetingdiff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.pyindex 6e13959ddf..be0cd9926e 100644--- a/jarvis/realtime/session.py+++ b/jarvis/realtime/session.py@@ -70,6 +70,15 @@ _AUDIO_SEND_TIMEOUT_S = 2.0# call that went deaf is visible for its whole duration, not only at onset._HALF_DUPLEX_MUTE_ALERT_S = 6.0_HALF_DUPLEX_MUTE_REPEAT_S = 10.0+# The RELEASE is far faster than the alert: ChatGPT-Live announces no+# terminal item (probe-confirmed 2026-08-06), so a turn that ends without a+# boundary used to hold the microphone shut a full six seconds — live logs+# showed "mute held 6.0 s ... 14.2 s" of deafness per stuck turn. Release+# once the mute AND the provider's audio have both been silent this long:+# above the adapter's 1.2 s quiescence backstop plus playback drain, so a+# reply that is merely pausing keeps its mute, and far below the alert. No+# audio playing means no echo risk — reopening matches barge-in semantics.+_HALF_DUPLEX_SILENT_RELEASE_S = 2.0# Per-turn stall backstop. A provider can stop emitting ENTIRELY — no audio, no# transcript, no boundary, no error — and the receive iterator then simply never# yields again. Nothing else in this module bounds that: the pump awaits the@@ -2173,13 +2182,20 @@ class RealtimeVoiceSession:self._half_duplex_muted_since = nowreturnmuted_s = now - self._half_duplex_muted_since- if muted_s < _HALF_DUPLEX_MUTE_ALERT_S:+ if muted_s < _HALF_DUPLEX_SILENT_RELEASE_S:returnsilent_since = self._last_output_audio_at or self._half_duplex_muted_sincesilent_s = now - silent_since- if silent_s >= _HALF_DUPLEX_MUTE_ALERT_S:+ if silent_s >= _HALF_DUPLEX_SILENT_RELEASE_S:self._mute_emergency_releases += 1- log.warning(+ log.log(+ # The fast release is the DESIGNED boundary-of-last-resort on+ # a transport with no terminal item; only a mute that somehow+ # survived past the alert threshold is pathological enough+ # for a WARNING.+ logging.WARNING+ if muted_s >= _HALF_DUPLEX_MUTE_ALERT_S+ else logging.INFO,"realtime[%s] releasing a half-duplex mute held %.1fs with no ""provider audio for %.1fs - the turn ended without a boundary, ""so the microphone is reopened rather than left deaf",diff --git a/tests/unit/realtime/test_codex_subscription.py b/tests/unit/realtime/test_codex_subscription.pyindex 48a4b268c7..6eeaa10fba 100644--- a/tests/unit/realtime/test_codex_subscription.py+++ b/tests/unit/realtime/test_codex_subscription.py@@ -3086,6 +3086,7 @@ async def test_a_rambling_opening_is_cut_and_the_real_answer_still_flows(refused frame by frame, and the answer the question earns still flowsthrough the continuation window afterwards."""monkeypatch.setattr(codex_subscription_mod, "_OPENING_RESPONSE_MAX_S", 0.2)+ monkeypatch.setattr(codex_subscription_mod, "_OPENING_OVERLAP_MAX_S", 0.2)loud = (1000).to_bytes(2, "little", signed=True) * 480transcriber = _ScheduledInputTranscriber([diff --git a/tests/unit/realtime/test_session.py b/tests/unit/realtime/test_session.pyindex c56c1bedee..4582b79920 100644--- a/tests/unit/realtime/test_session.py+++ b/tests/unit/realtime/test_session.py@@ -7129,3 +7129,44 @@ async def test_shadow_transcript_clears_the_gate_without_reaching_the_surface():]assert surfaced == [], "shadow text must never reach the surface"await sess.end(reason="test")+++async def test_a_turn_without_a_boundary_releases_the_microphone_fast() -> None:+ """ChatGPT-Live announces no terminal item (probe-confirmed 2026-08-06):+ a turn whose backstop never fires used to hold the half-duplex mute six+ full seconds. The release now needs only ~2 s of provider silence - and a+ reply that is still streaming keeps its mute."""+ provider = SubscriptionLikeProvider([])+ sess = _half_duplex_session(provider)+ await sess.handle_control({"type": "audio_start", "sample_rate": 24_000})+ wire = provider.session++ # Assistant audio opens the output: the microphone mutes.+ wire.queue.put_nowait(RealtimeEvent(type="audio_delta", audio=_pcm_chunk()))+ for _ in range(50):+ await asyncio.sleep(0.01)+ if sess._output_active: # noqa: SLF001+ break+ assert sess._output_active is True # noqa: SLF001++ # The provider goes silent WITHOUT any boundary. Keep feeding microphone+ # frames like the live pipeline does.+ mic_frame = b"\x11\x22" * 480+ released_after = None+ start = asyncio.get_event_loop().time()+ while asyncio.get_event_loop().time() - start < 4.0:+ await sess.handle_audio_frame(mic_frame)+ await asyncio.sleep(0.05)+ if wire.sent_audio:+ released_after = asyncio.get_event_loop().time() - start+ break+ assert released_after is not None, "the microphone stayed deaf"+ assert released_after >= 1.5, (+ f"released after {released_after:.2f}s - a streaming reply must keep "+ "its mute for the full silent-release window"+ )+ assert released_after < 3.5, (+ f"released only after {released_after:.2f}s - the fast release "+ "should fire at ~2 s of provider silence"+ )+ await sess.end(reason="test")