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
feat(realtime): audit capability-limited handoffs
rubenluetke10-beepc4959ba1bdc5
diff --git a/docs/codex-subscription-realtime-voice.md b/docs/codex-subscription-realtime-voice.mdindex a6fa29ab54..e6757ba750 100644--- a/docs/codex-subscription-realtime-voice.md+++ b/docs/codex-subscription-realtime-voice.md@@ -469,26 +469,20 @@ For every supported upgrade:5. Update the user-facing experimental warning if OpenAI changes plan orconnected-Voice accounting.-## Parity roadmap+## Parity status and remaining roadmapOrdered. Each step keeps this path equivalent to API-key realtime; none ofthem changes the trade-off above, which is a property of the wire.-1. **Make the handoff obligation observable.** The model deciding *not* to- hand off is the only silent action failure left here. Count handoffs per- call alongside delegate dispatches and emit one bounded log line when a- call produces user turns that a `realtime_tool_mode = "direct"` API session- would have turned into tool calls. That converts a prompt regression from- "users say it got lazy" into a number. Do **not** add local intent- detection that starts actions the model never requested — considered and- rejected as too willing to act.-2. **Pin the substitution with a contract test.**- `tests/contract/test_realtime_provider_contract.py` asserts the capability- flags but not the behaviour behind them. Add: every installed provider with- `supports_direct_tools = False` must resolve to a delegate-backed action- path when a callable brain exists, and must decline rather than fail when- it does not. This is what stops a future refactor from quietly restoring- the terminal failure.+1. **Handoff observability is complete.** Every capability-limited call now+ records planner-confirmed action turns, provider handoff requests, actual+ deterministic delegate dispatches, declines, and handoff-obligation misses+ in `RealtimeSessionPostmortem`. Calls with action turns emit one bounded,+ content-free summary line; no new intent detector can initiate actions.+2. **The substitution is contract-pinned.** The provider contract suite now+ requires every installed provider with `supports_direct_tools = False` to+ resolve a callable brain to the delegate path and to decline an unavailable+ handoff audibly without ending the call.3. **Wayland-only browser hand-off.** Establish whether `codex` can open abrowser on a pure-Wayland session without XWayland. If it cannot, theprinted device-code URL is the honest answer and the card should say sodiff --git a/jarvis/core/events.py b/jarvis/core/events.pyindex eefc7e397b..171e8da828 100644--- a/jarvis/core/events.py+++ b/jarvis/core/events.py@@ -1675,6 +1675,16 @@ class RealtimeSessionPostmortem(Event):opening_responses_bounded: int = 0#: Self-dialogue verdicts that forced a transport replacement (BUG-124).self_dialogue_rebuilds: int = 0+ #: Planner-confirmed action turns on a provider without native tools.+ handoff_action_turns: int = 0+ #: Provider handoff control events received during the call.+ handoff_requests: int = 0+ #: Deterministic delegate jobs actually started on that transport.+ handoff_delegate_dispatches: int = 0+ #: Handoffs declined because no usable request/delegate was available.+ handoff_declines: int = 0+ #: Action turns where the provider omitted its required handoff event.+ handoff_obligation_misses: int = 0#: Half-duplex mutes released by the emergency timer, not a turn boundary.mute_emergency_releases: int = 0#: Microphone sender wall-clock resyncs (mic audio lost to a stall).diff --git a/jarvis/diagnostics/realtime_forensics.py b/jarvis/diagnostics/realtime_forensics.pyindex ed8c237833..67d5fb044a 100644--- a/jarvis/diagnostics/realtime_forensics.py+++ b/jarvis/diagnostics/realtime_forensics.py@@ -120,6 +120,17 @@ def evaluate_postmortem(pm: Mapping[str, Any]) -> list[RealtimeFinding]:))+ handoff_misses = _count(pm, "handoff_obligation_misses")+ if handoff_misses:+ add(+ RealtimeFinding(+ "high" if handoff_misses >= 2 else "warn",+ "handoff-obligation-miss",+ f"{handoff_misses} planner-confirmed action turn(s) did not "+ "receive the provider's required handoff control event",+ )+ )+mutes = _count(pm, "mute_emergency_releases")if mutes:add(diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.pyindex b72a2403d8..0168edca30 100644--- a/jarvis/realtime/session.py+++ b/jarvis/realtime/session.py@@ -1343,6 +1343,15 @@ class RealtimeVoiceSession:self._language_flips = 0self._close_timed_out = Falseself._adapter_diag_accum: Counter[str] = Counter()+ # Capability-limited action-path observability. These counters never+ # classify or execute a request; they record decisions the existing+ # turn planner/provider already made so a prompt-level handoff miss is+ # visible after the call instead of presenting as "the agent got lazy."+ self._handoff_action_turns = 0+ self._handoff_requests = 0+ self._handoff_delegate_dispatches = 0+ self._handoff_declines = 0+ self._handoff_action_seen_for_turn = Falsebrain_config = getattr(self._config, "brain", None)reply_language = str(@@ -2952,6 +2961,13 @@ class RealtimeVoiceSession:).strip()if event.is_final and input_observed:turn_plan = self._plan_turn(self._last_user_text)+ if (+ turn_plan.requires_orchestrator+ and not self._active_provider_supports_direct_tools()+ and not self._handoff_action_seen_for_turn+ ):+ self._handoff_action_turns += 1+ self._handoff_action_seen_for_turn = Truereasons = ",".join(sorted(reason.value for reason in turn_plan.reasons)) or "none"@@ -3202,6 +3218,8 @@ class RealtimeVoiceSession:handoff_text = _dictionary_corrected(str(getattr(event, "text", "") or "").strip())+ if not self._active_provider_supports_direct_tools():+ self._handoff_requests += 1if handoff_text and not self._last_user_text:self._last_user_text = handoff_textself._input_turn_observed = True@@ -5405,6 +5423,7 @@ class RealtimeVoiceSession:self._turn_final_text = ""self._surface_spoke_this_turn = Falseself._delegate_required_for_turn = False+ self._handoff_action_seen_for_turn = Falseself._deferred_provider_speech_start = Falseself._scrub_cancelled_for_turn = Falseself._embedded_silence_ms = 0.0@@ -6102,6 +6121,8 @@ class RealtimeVoiceSession:if turn_state.dispatch_started or turn_state.result_complete:returnturn_state.dispatch_started = True+ if not self._active_provider_supports_direct_tools():+ self._handoff_delegate_dispatches += 1self._mark_latency_named("REALTIME_DELEGATE_STARTED",detail="kind=deterministic",@@ -6134,6 +6155,8 @@ class RealtimeVoiceSession:"""from jarvis.voice.action_phrases import action_phrase # noqa: PLC0415+ if not self._active_provider_supports_direct_tools():+ self._handoff_declines += 1log.warning("realtime[%s] provider handoff declined: %s",self.session_id,@@ -7150,6 +7173,28 @@ class RealtimeVoiceSession:exc_info=True,)+ def _active_provider_supports_direct_tools(self) -> bool:+ """Return the current provider's action-wire capability."""+ return bool(getattr(self._provider, "supports_direct_tools", True))++ def _log_handoff_observability(self) -> None:+ """Emit one content-free summary when handoffs mattered this call."""+ if self._handoff_action_turns <= 0:+ return+ misses = max(0, self._handoff_action_turns - self._handoff_requests)+ logger = log.warning if misses else log.info+ logger(+ "realtime[%s] capability-limited action audit: action_turns=%d "+ "handoff_requests=%d delegate_dispatches=%d declines=%d "+ "handoff_obligation_misses=%d",+ self.session_id,+ self._handoff_action_turns,+ self._handoff_requests,+ self._handoff_delegate_dispatches,+ self._handoff_declines,+ misses,+ )+def _build_postmortem(self, reason: str) -> Any:"""Assemble the RealtimeSessionPostmortem event from all counters."""from jarvis.core.events import RealtimeSessionPostmortem@@ -7188,6 +7233,13 @@ class RealtimeVoiceSession:sequenced_boundaries=diag.get("sequenced_boundaries", 0),opening_responses_bounded=diag.get("opening_responses_bounded", 0),self_dialogue_rebuilds=diag.get("self_dialogue_rebuilds", 0),+ handoff_action_turns=self._handoff_action_turns,+ handoff_requests=self._handoff_requests,+ handoff_delegate_dispatches=self._handoff_delegate_dispatches,+ handoff_declines=self._handoff_declines,+ handoff_obligation_misses=max(+ 0, self._handoff_action_turns - self._handoff_requests+ ),mute_emergency_releases=self._mute_emergency_releases,sender_pacing_resyncs=diag.get("sender_pacing_resyncs", 0),sender_shed_frames=diag.get("sender_shed_frames", 0),@@ -7328,6 +7380,7 @@ class RealtimeVoiceSession:# it. The flight recorder is its consumer.if self._session is not None:self._harvest_adapter_diagnostics(self._session)+ self._log_handoff_observability()if self._bus is not None:try:await self._bus.publish(diff --git a/tests/contract/test_realtime_provider_contract.py b/tests/contract/test_realtime_provider_contract.pyindex d513ac63bf..9520c1c295 100644--- a/tests/contract/test_realtime_provider_contract.py+++ b/tests/contract/test_realtime_provider_contract.py@@ -1,7 +1,10 @@from __future__ import annotationsimport ast+import asynciofrom pathlib import Path+from types import SimpleNamespace+from typing import Anyimport pytest@@ -13,7 +16,81 @@ from jarvis.plugins.realtime.openai_realtime import (LocalRealtimeProvider,OpenAIRealtimeProvider,)-from jarvis.realtime.protocol import RealtimeProvider+from jarvis.realtime.protocol import RealtimeEvent, RealtimeProvider+from jarvis.realtime.session import RealtimeVoiceSession++_CAPABILITY_LIMITED_PROVIDER_CLASSES = tuple(+ provider_cls+ for provider_cls in (CodexSubscriptionRealtimeProvider,)+ if not bool(getattr(provider_cls, "supports_direct_tools", True))+)+++def _session_config(tool_mode: str) -> SimpleNamespace:+ return SimpleNamespace(+ brain=SimpleNamespace(reply_language="en", providers={}),+ stt=SimpleNamespace(language="auto"),+ voice=SimpleNamespace(mode="realtime", realtime_tool_mode=tool_mode),+ latency=SimpleNamespace(enabled=False),+ )+++class _CallableBrain:+ async def __call__(self, text: str) -> str:+ return f"handled: {text}"+++class _HandoffWire:+ session_id = "contract-wire"+ creates_responses_automatically = False+ isolates_response_generations = False+ supports_tool_updates = False+ direct_speech_is_authoritative = True++ def __init__(self, events: tuple[RealtimeEvent, ...]) -> None:+ self._events = events+ self.spoken: list[str] = []++ async def receive(self):+ for event in self._events:+ yield event+ await asyncio.sleep(0)++ async def update_session(self, **kwargs: Any) -> None:+ del kwargs++ async def request_response(self, **kwargs: Any) -> None:+ del kwargs++ async def send_speech(self, text: str) -> None:+ self.spoken.append(text)++ async def interrupt(self, **kwargs: Any) -> None:+ del kwargs++ async def truncate(self, **kwargs: Any) -> None:+ del kwargs++ async def close(self) -> None:+ return None+++class _CapabilityWrapper:+ supports_realtime = True+ input_sample_rate = 24_000+ output_sample_rate = 24_000+ supports_direct_tools = False++ def __init__(self, installed: Any, wire: _HandoffWire) -> None:+ self.name = installed.name+ self._wire = wire++ async def can_open_duplex_session(self) -> bool:+ return True++ async def open_session(self, cfg: Any) -> _HandoffWire:+ del cfg+ return self._wire@pytest.mark.parametrize(@@ -47,6 +124,71 @@ def test_subscription_provider_is_structurally_conformant_without_api_key() -> Nassert provider.requires_webrtc_offer is False[email protected]("provider_cls", _CAPABILITY_LIMITED_PROVIDER_CLASSES)+def test_capability_limited_provider_resolves_callable_brain_to_delegate(+ provider_cls: type[Any],+) -> None:+ """No-native-tools providers retain an action path in direct mode."""+ provider = provider_cls()+ session = RealtimeVoiceSession(+ session_id="contract-delegate",+ send_binary=lambda _data: asyncio.sleep(0),+ send_json=lambda _message: asyncio.sleep(0),+ provider=provider,+ config=_session_config("direct"),+ brain=_CallableBrain(),+ )++ assert session._delegate_forced_by_provider is True+ assert session._delegate_enabled is True++[email protected]("provider_cls", _CAPABILITY_LIMITED_PROVIDER_CLASSES)+async def test_capability_limited_provider_declines_handoff_without_ending_call(+ provider_cls: type[Any],+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """Losing the delegate costs one action, never the live conversation."""+ from jarvis.core import runtime_refs++ monkeypatch.setattr(runtime_refs, "get_supervisor_tool_gateway", lambda: None)+ installed = provider_cls()+ wire = _HandoffWire(+ (+ RealtimeEvent(+ type="input_transcript",+ text="Open the settings view.",+ is_final=True,+ ),+ RealtimeEvent(+ type="handoff_requested",+ text="Open the settings view.",+ handoff_id="contract-handoff",+ ),+ RealtimeEvent(type="output_transcript_delta", text="Still here."),+ RealtimeEvent(type="turn_complete"),+ )+ )+ messages: list[dict[str, Any]] = []+ session = RealtimeVoiceSession(+ session_id="contract-decline",+ send_binary=lambda _data: asyncio.sleep(0),+ send_json=lambda message: messages.append(message) or asyncio.sleep(0),+ provider=_CapabilityWrapper(installed, wire),+ config=_session_config("delegate"),+ brain=None,+ )++ await session.handle_control({"type": "audio_start", "sample_rate": 24_000})+ await session.wait_finished()++ assert wire.spoken, "the unavailable action must be declined audibly"+ assert not [item for item in messages if item.get("type") == "provider_error"]+ assert any(item.get("type") == "turn_complete" for item in messages)+ await session.end(reason="contract")++def test_local_provider_is_structurally_conformant_without_api_key() -> None:"""The self-hosted card joined every roster except this one (found inthe 2026-08-08 hardening review) — its protocol conformance was pinneddiff --git a/tests/unit/diagnostics/test_realtime_forensics.py b/tests/unit/diagnostics/test_realtime_forensics.pyindex 23823fd2d3..7b87248f6e 100644--- a/tests/unit/diagnostics/test_realtime_forensics.py+++ b/tests/unit/diagnostics/test_realtime_forensics.py@@ -41,6 +41,7 @@ def test_every_failure_class_maps_to_its_finding() -> None:"ungrounded_captions_dropped": 3,"ungrounded_responses_refused": 7,"self_dialogue_rebuilds": 1,+ "handoff_obligation_misses": 2,"mute_emergency_releases": 2,"max_loop_stall_ms": 15_000,"sender_pacing_resyncs": 1,@@ -59,6 +60,7 @@ def test_every_failure_class_maps_to_its_finding() -> None:"ungrounded-caption-storm","refusal-storm","self-dialogue",+ "handoff-obligation-miss","mute-emergency-release","event-loop-stall","sender-behind-wall-clock",@@ -90,6 +92,12 @@ def test_severity_boundaries_hold() -> None:assert _kinds(_healthy() | {"first_audio_ms": 0}) == set()# One language flip is normal conversation behaviour (de -> en on purpose).assert _kinds(_healthy() | {"language_flips": 1}) == set()+ one_handoff_miss = evaluate_postmortem(+ _healthy() | {"handoff_obligation_misses": 1}+ )+ assert [(f.severity, f.kind) for f in one_handoff_miss] == [+ ("warn", "handoff-obligation-miss")+ ]def test_extract_postmortems_reads_both_capture_shapes() -> None:diff --git a/tests/unit/realtime/test_session.py b/tests/unit/realtime/test_session.pyindex 016bc45ce8..41374622b1 100644--- a/tests/unit/realtime/test_session.py+++ b/tests/unit/realtime/test_session.py@@ -2059,7 +2059,9 @@ async def test_direct_mode_uses_delegate_when_provider_cannot_declare_tools():@pytest.mark.asyncio-async def test_capability_forced_delegate_executes_provider_handoff():+async def test_capability_forced_delegate_executes_provider_handoff(caplog):+ caplog.set_level("INFO")+class NoDirectToolsProvider(FakeProvider):supports_direct_tools = False@@ -2094,6 +2096,11 @@ async def test_capability_forced_delegate_executes_provider_handoff():assert brain.calls[0][0] == "Open the settings view."assert not [item for item in jsons if item.get("type") == "provider_error"]await sess.end(reason="test")+ assert sess._handoff_action_turns == 1+ assert sess._handoff_requests == 1+ assert sess._handoff_delegate_dispatches == 1+ assert sess._handoff_declines == 0+ assert "handoff_obligation_misses=0" in caplog.text@pytest.mark.asyncio@@ -2141,6 +2148,10 @@ async def test_handoff_without_a_delegate_declines_instead_of_ending_the_call():# The stream kept being consumed after the refusal.assert any(item.get("type") == "turn_complete" for item in jsons)await sess.end(reason="test")+ assert sess._handoff_action_turns == 1+ assert sess._handoff_requests == 1+ assert sess._handoff_delegate_dispatches == 0+ assert sess._handoff_declines == 1@pytest.mark.asynciodiff --git a/tests/unit/realtime/test_session_postmortem.py b/tests/unit/realtime/test_session_postmortem.pyindex ad3d4d38e7..8fe5530f45 100644--- a/tests/unit/realtime/test_session_postmortem.py+++ b/tests/unit/realtime/test_session_postmortem.py@@ -141,6 +141,10 @@ async def test_end_publishes_one_postmortem_with_adapter_counters() -> None:})session, seen = await _open(wire)+ session._handoff_action_turns = 2 # noqa: SLF001 - postmortem inputs+ session._handoff_requests = 1 # noqa: SLF001 - postmortem inputs+ session._handoff_delegate_dispatches = 2 # noqa: SLF001 - postmortem inputs+ session._handoff_declines = 1 # noqa: SLF001 - postmortem inputsawait asyncio.wait_for(session.end(reason="hotkey"), TIMEOUT_S)@@ -152,6 +156,11 @@ async def test_end_publishes_one_postmortem_with_adapter_counters() -> None:assert event.ungrounded_captions_dropped == 2assert event.quiescence_boundary_turns == 2assert event.sender_pacing_resyncs == 1+ assert event.handoff_action_turns == 2+ assert event.handoff_requests == 1+ assert event.handoff_delegate_dispatches == 2+ assert event.handoff_declines == 1+ assert event.handoff_obligation_misses == 1assert event.ready_ms >= 0assert event.close_clean is True