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): deterministically delegate the turn that answers a pending voice confirmation
Ruben Lütke9eed35e56d2c
diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.pyindex 0f47466f33..f5a2844316 100644--- a/jarvis/realtime/session.py+++ b/jarvis/realtime/session.py@@ -794,6 +794,7 @@ class RealtimeVoiceSession:self._delegate_required_for_turn = (self._delegate_required_for_turnor turn_plan.requires_orchestrator+ or self._brain_awaits_voice_confirm())refresh_tools = getattr(self._tool_bridge, "refresh_from_source", None@@ -1457,6 +1458,24 @@ class RealtimeVoiceSession:return _TOOL_ROLE_DIRECTIVEreturn ""+ def _brain_awaits_voice_confirm(self) -> bool:+ """True while the classic brain holds a two-turn ask-tier confirmation.++ The pending yes/no answer must reach the brain's confirmation resume+ deterministically: a bare answer ("yes", "no") never matches the+ planner's action vocabulary, so without this probe the confirmed+ ask-tier action would depend on the provider voluntarily calling+ ``jarvis_action`` — prompt compliance is not a correctness boundary+ (BUG-047 class rule).+ """+ probe = getattr(self._brain, "has_pending_voice_confirm", None)+ if not callable(probe):+ return False+ try:+ return bool(probe())+ except Exception: # noqa: BLE001 — a probe failure must not stall the turn+ return False+def _delegate_delivery_started(self) -> bool:state = self._delegate_turns.get(self._turn_id)return bool(diff --git a/tests/unit/realtime/test_session.py b/tests/unit/realtime/test_session.pyindex 088dd534c4..98673c8ee2 100644--- a/tests/unit/realtime/test_session.py+++ b/tests/unit/realtime/test_session.py@@ -1790,6 +1790,69 @@ async def test_general_knowledge_turn_keeps_native_realtime_answering(utterance)await sess.end(reason="test")+class _ConfirmAwaitingBrain(FakeBrain):+ """FakeBrain that reports a pending two-turn voice confirmation."""++ def __init__(self, *args, pending=True, **kwargs):+ super().__init__(*args, **kwargs)+ self.pending = pending++ def has_pending_voice_confirm(self):+ return self.pending+++async def test_pending_voice_confirm_forces_deterministic_delegation():+ """A bare yes/no answer must reach the brain's confirmation resume.++ "Ja, gerne." matches no planner action vocabulary, so without the+ pending-confirm probe the armed ask-tier action would depend on the+ provider voluntarily calling jarvis_action.+ """+ brain = _ConfirmAwaitingBrain(replies=("The email was sent.",))+ provider = FakeProvider(+ [+ RealtimeEvent(+ type="input_transcript",+ text="Ja, gerne.", # i18n-allow: German speech-input fixture+ is_final=True,+ )+ ]+ )+ sess = _session(provider, brain=brain)++ await sess.handle_control({"type": "audio_start", "sample_rate": 16_000})+ await sess.wait_finished()+ await asyncio.sleep(0.12)++ assert brain.calls[0][0] == "Ja, gerne." # i18n-allow: fixture echo+ assert provider.session.text_inputs+ assert "<trusted_action_result>" in provider.session.text_inputs[-1]+ await sess.end(reason="test")+++async def test_bare_answer_without_pending_confirm_stays_native():+ brain = _ConfirmAwaitingBrain(pending=False)+ provider = FakeProvider(+ [+ RealtimeEvent(+ type="input_transcript",+ text="Ja, gerne.", # i18n-allow: German speech-input fixture+ is_final=True,+ )+ ]+ )+ sess = _session(provider, brain=brain)++ await sess.handle_control({"type": "audio_start", "sample_rate": 16_000})+ await sess.wait_finished()++ assert brain.calls == []+ assert provider.session.required_tools == [None]+ await sess.end(reason="test")++@pytest.mark.asyncioasync def test_automatic_provider_wiki_turn_runs_brain_without_tool_call():brain = FakeBrain(replies=("The Wiki entry was saved.",))