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.

feat(realtime): add realtime latency phases to the single-source enum

Ruben Lütke4c7f84940c03
diff --git a/jarvis/core/events.py b/jarvis/core/events.py
index 9ca6eec5d4..c664297ca8 100644
--- a/jarvis/core/events.py
+++ b/jarvis/core/events.py
@@ -962,6 +962,14 @@ class LatencyPhase(StrEnum):
TTS_REQUEST_SENT = "tts_request_sent" # noqa: S105
TTS_FIRST_CHUNK = "tts_first_chunk"
TTS_STREAM_DONE = "tts_stream_done"
+ # Realtime duplex voice mode (browser/OpenAI). REALTIME_INPUT_COMMITTED is
+ # the per-turn anchor + stall-guard reset point; FIRST_TRANSCRIPT is the
+ # BrainTTFT-equivalent; FIRST_AUDIO is the first provider audio delta
+ # received (pre scrub-hold). AudioOutFirst still marks the first audible,
+ # post-hold sample.
+ REALTIME_INPUT_COMMITTED = "realtime_input_committed"
+ REALTIME_FIRST_TRANSCRIPT = "realtime_first_transcript"
+ REALTIME_FIRST_AUDIO = "realtime_first_audio"
_LATENCY_PHASE_VALUES: frozenset[str] = frozenset(p.value for p in LatencyPhase)
diff --git a/tests/unit/core/test_realtime_latency_phases.py b/tests/unit/core/test_realtime_latency_phases.py
new file mode 100644
index 0000000000..13471f080c
--- /dev/null
+++ b/tests/unit/core/test_realtime_latency_phases.py
@@ -0,0 +1,20 @@
+from uuid import uuid4
+
+from jarvis.core.events import LatencyPhase, LatencySpan
+
+
+def test_realtime_phases_exist_and_are_accepted_by_the_span_guard():
+ for phase in (
+ LatencyPhase.REALTIME_INPUT_COMMITTED,
+ LatencyPhase.REALTIME_FIRST_TRANSCRIPT,
+ LatencyPhase.REALTIME_FIRST_AUDIO,
+ ):
+ span = LatencySpan(trace_id=uuid4(), phase=phase.value, duration_ms=1.0)
+ assert span.phase == phase.value
+
+
+def test_unknown_realtime_phase_still_rejected():
+ import pytest
+
+ with pytest.raises(ValueError):
+ LatencySpan(trace_id=uuid4(), phase="realtime_not_a_phase")