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(realtime): stop a dying socket from holding the microphone the user asked for

rubenluetke10-beep65bcf6e67c4c
diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.py
index 94206c37ac..90d745a8af 100644
--- a/jarvis/realtime/session.py
+++ b/jarvis/realtime/session.py
@@ -173,6 +173,15 @@ _TRANSPORT_REBUILD_MAX_PER_WINDOW = 3
# seconds) so the fresh transport gets a fair chance to work, short enough that
# a genuinely healed call never trips it (BUG-124).
_ADVISED_REBUILD_RELAPSE_S = 15.0
+# How long the teardown waits for the provider socket to close politely before
+# abandoning it. This is a CEILING on a best-effort courtesy, not a duration
+# anything needs: a socket that has not closed by now is not about to. It used
+# to be 5 s — exactly the dictation handover's own bound
+# (``pipeline._DICTATION_HANDOVER_TIMEOUT_S``), so a hangup made to free the
+# microphone held it for the full window and the key press that asked for it
+# was refused (live 2026-08-06 17:42:07 → 17:42:12, "nothing was recorded").
+# Whatever waits for the microphone must have room to outlast this.
+_PROVIDER_CLOSE_BOUND_S = 1.5
_CREDENTIAL_TERMINAL_STATUSES = frozenset(
{BAD_KEY, NO_CREDITS, NOT_CONFIGURED}
)
@@ -6846,7 +6855,9 @@ class RealtimeVoiceSession:
# deaf until the socket eventually gives up (~20 s live 2026-07-23).
# Bound it: abandon the socket so the hangup always completes.
try:
- await asyncio.wait_for(self._session.close(), timeout=5.0)
+ await asyncio.wait_for(
+ self._session.close(), timeout=_PROVIDER_CLOSE_BOUND_S
+ )
except TimeoutError:
log.warning(
"realtime[%s] provider close timed out during end(); "
diff --git a/tests/unit/realtime/test_session.py b/tests/unit/realtime/test_session.py
index 97a85d7b88..c56c1bedee 100644
--- a/tests/unit/realtime/test_session.py
+++ b/tests/unit/realtime/test_session.py
@@ -6160,6 +6160,22 @@ async def test_advised_reconnect_defers_to_the_turn_boundary_mid_turn():
await sess.end(reason="test")
+def test_the_socket_courtesy_never_outlasts_what_waits_for_the_microphone():
+ """A hangup made to free the microphone must not hold it for the wait.
+
+ Live 2026-08-06 17:42: the dictation key hung the call up, the provider
+ socket took its full 5 s bound to give up — the same 5 s the handover was
+ willing to wait — and the press was refused with "nothing was recorded".
+ The close is a best-effort courtesy; the person reaching for the key is
+ not. Pinned as a RELATIONSHIP, because the bug was the two numbers being
+ equal, not either number itself.
+ """
+ from jarvis.realtime.session import _PROVIDER_CLOSE_BOUND_S
+ from jarvis.speech.pipeline import _DICTATION_HANDOVER_TIMEOUT_S
+
+ assert _PROVIDER_CLOSE_BOUND_S * 2 <= _DICTATION_HANDOVER_TIMEOUT_S
+
+
@pytest.mark.asyncio
async def test_the_same_advice_right_after_a_rebuild_ends_the_call_honestly():
"""BUG-124: a rebuild that has to be repeated for the same cause failed.