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): promise-block recovery dispatches despite a missing provider boundary

Ruben Lütkeca615e27a82a
diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.py
index 7ffb119e6c..5a9fc03b0b 100644
--- a/jarvis/realtime/session.py
+++ b/jarvis/realtime/session.py
@@ -284,6 +284,10 @@ class _DelegateTurnState:
bridge_transcript_parts: list[str] = field(default_factory=list)
bridge_audio_chunks: list[Any] = field(default_factory=list)
wait_for_provider_boundary: bool = False
+ # True when the dispatching path KNOWS the input transcript is complete
+ # (e.g. the provider already produced a response for it). A missing
+ # provider boundary may then delay the dispatch but never veto it.
+ input_final: bool = False
input_boundary_ready: asyncio.Event = field(default_factory=asyncio.Event)
provider_ready: asyncio.Event = field(default_factory=asyncio.Event)
result_ready: asyncio.Event = field(default_factory=asyncio.Event)
@@ -1515,6 +1519,13 @@ class RealtimeVoiceSession:
_DelegateTurnState(deterministic=True),
)
turn_state.wait_for_provider_boundary = True
+ # The provider already produced a response for this input, so the
+ # transcript is final by construction. When the interrupt lands on
+ # an already-completed response, no further turn_complete arrives
+ # and the boundary wait times out — that must delay the dispatch,
+ # never veto it (live forensic 2026-07-15 07:59: the recovery
+ # spoke a canned failure without ever dispatching the action).
+ turn_state.input_final = True
try:
await self._session.interrupt()
except Exception: # noqa: BLE001, S110 — provider may already be done
@@ -2628,7 +2639,13 @@ class RealtimeVoiceSession:
timeout=_DELEGATE_INPUT_BOUNDARY_WAIT_S,
)
except TimeoutError:
- boundary_ready = False
+ # The refusal below protects against acting on a PARTIAL
+ # input transcript. When the dispatching path marked the
+ # input final, the missing provider boundary is only a
+ # wire artifact (an interrupt that landed on an
+ # already-completed response) — proceed; result delivery
+ # still waits for its own provider boundary.
+ boundary_ready = turn_state.input_final
else:
# A manual-response provider may already have queued a native
# function call or cancelled output behind the final input
diff --git a/tests/unit/realtime/test_session.py b/tests/unit/realtime/test_session.py
index 0b05cccd72..1557e4d4bc 100644
--- a/tests/unit/realtime/test_session.py
+++ b/tests/unit/realtime/test_session.py
@@ -2449,6 +2449,79 @@ async def test_slow_deterministic_delegate_speaks_a_bridge_line(monkeypatch):
await sess.end(reason="test")
+class _StalledPromiseSession(FakeSession):
+ """Answer with an unbacked action promise, then never complete the turn.
+
+ Live forensic 2026-07-15 07:59: the promise-block guard interrupted a
+ response that was already complete on the wire, so no further
+ turn_complete arrived. The deterministic recovery then timed out waiting
+ for the provider boundary and refused the action outright — the user heard
+ a canned failure although the full final input transcript was in hand.
+ """
+
+ def __init__(self, *, released):
+ super().__init__([])
+ self._released = released
+
+ async def receive(self):
+ yield RealtimeEvent(
+ type="input_transcript",
+ text="That is not the right server.",
+ is_final=True,
+ )
+ yield RealtimeEvent(
+ type="output_transcript_delta",
+ text="I'll check and get back to you.",
+ )
+ await self._released.wait()
+
+
+class _StalledPromiseProvider(FakeProvider):
+ def __init__(self, *, released):
+ super().__init__([])
+ self._released = released
+
+ async def open_session(self, cfg):
+ self.opened_with = cfg
+ self.session = _StalledPromiseSession(released=self._released)
+ return self.session
+
+
+async def test_blocked_action_promise_still_dispatches_after_boundary_timeout(
+ monkeypatch,
+):
+ """The promise-block recovery must run the action, not refuse it.
+
+ The input transcript is final by construction on this path (the provider
+ already produced a response for it), so a missing provider boundary after
+ the interrupt may delay the dispatch but never veto it.
+ """
+ monkeypatch.setattr(
+ "jarvis.realtime.session._DELEGATE_INPUT_BOUNDARY_WAIT_S", 0.05
+ )
+ released = asyncio.Event()
+ brain = FakeBrain(replies=("Switched to the right server.",))
+ provider = _StalledPromiseProvider(released=released)
+ sess = _session(provider, brain=brain)
+
+ await sess.handle_control({"type": "audio_start", "sample_rate": 16_000})
+ async with asyncio.timeout(2):
+ while not provider.session.text_inputs:
+ await asyncio.sleep(0.01)
+
+ assert brain.calls, "the recovery must dispatch the brain turn"
+ assert brain.calls[0][0] == "That is not the right server."
+ result = provider.session.text_inputs[-1]
+ assert "<trusted_action_result>" in result
+ assert "Switched to the right server." in result
+ assert "Result status: success" in result
+
+ released.set()
+ await sess.wait_finished()
+ await sess.end(reason="test")
+
+
@pytest.mark.asyncio
async def test_fast_deterministic_delegate_needs_no_bridge_line(monkeypatch):
"""A result faster than the bridge delay keeps the turn chatter-free."""