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): keep ONE voice for the whole call — deep replies speak through the deterministic surface TTS (BUG-086 escalation)

Personal Jarvis Maintainer7baf587e042d
diff --git a/docs/BUGS.md b/docs/BUGS.md
index 3e82912fcd..822a8018e6 100644
--- a/docs/BUGS.md
+++ b/docs/BUGS.md
@@ -5917,7 +5917,7 @@ released by a message from the (now dead) transport will wedge; whoever
declares the old turn finished must broadcast that fact to all surfaces,
not just to the recorder.
-## BUG-086: Realtime voice audibly flips gender between turns while every transcript label reads the same pinned voice (HIGH, MITIGATED 2026-07-18, provider-side root cause OPEN)
+## BUG-086: Realtime voice audibly flips gender between turns while every transcript label reads the same pinned voice (HIGH, MITIGATED 2026-07-18, ESCALATION SHIPPED 2026-07-21, provider-side root cause OPEN)
**Symptom (live 2026-07-18 17:12, session `f4e8e93d`, gemini-live,
4 turns).** The audible voice alternated male / female / male /
@@ -5962,12 +5962,29 @@ plain persona turns — a standing session-wide clause in
`_REALTIME_SAFETY_APPENDIX` ("keep one single, consistent voice for the
entire conversation; never switch voice, gender, tone").
+**Escalation shipped (2026-07-21, maintainer report: the voice still
+flipped mid-call, especially on deep-thinking replies).** Delegate replies
+are no longer read back by the generative native renderer at all: the
+provider session declares the capability `renders_pinned_voice = False`
+(`_GeminiLiveSession`; documented in `jarvis/realtime/protocol.py`,
+default True when absent — a capability gate, never a provider-name pin,
+AP-21), and `RealtimeVoiceSession._verify_delegate_readback` then claims
+the reply for the desktop surface IMMEDIATELY instead of waiting out the
+no-readback window: the same-family surface TTS (`gemini-flash-tts`,
+one-take, pinned session voice) speaks it, while the trusted result is
+still injected so the live model keeps conversational context — its own
+(re-)rendering stays withheld via the existing one-reply-one-voice flags.
+The browser surface keeps the native readback: it has no server-side
+rendering for `error_spoken`, and its Web-Speech fallback would be a THIRD
+voice. Guards:
+`tests/unit/realtime/test_session.py::test_generative_voice_provider_delegate_reply_is_spoken_by_the_surface`
+and `::test_generative_voice_provider_keeps_native_readback_on_the_browser_surface`.
+
**Still OPEN.**
-- The provider can still drift despite instructions; if it does, the next
- escalation is rendering delegate results through the surface TTS
- (deterministic voice) instead of native readback — trading first-audio
- latency for voice identity.
+- Plain (non-delegate) native turns can still drift despite the standing
+ session clause — inherent to a generative renderer; a full fix would
+ abandon native audio entirely.
- Label honesty: `voice_name` should distinguish "requested" from
"verified" (classic TTS engines are verified by construction; native
realtime audio is only ever requested). Until then, treat realtime
diff --git a/jarvis/plugins/realtime/gemini_live.py b/jarvis/plugins/realtime/gemini_live.py
index b80d611b0f..2538197031 100644
--- a/jarvis/plugins/realtime/gemini_live.py
+++ b/jarvis/plugins/realtime/gemini_live.py
@@ -57,6 +57,14 @@ class _GeminiLiveSession:
# reason=error (BUG-071). This adapter has no in-protocol resume, so the
# orchestrator may reopen a fresh session in place and continue the call.
rebuild_on_transport_death = True
+ # Gemini's native audio is a GENERATIVE renderer, not a fixed-voice
+ # synthesizer: the pinned prebuilt voice is a starting point the model
+ # can audibly drift from when the spoken content reads as a performance
+ # cue — observed live as gender flips between turns of one call
+ # (BUG-086). Declaring this lets the orchestrator speak trusted delegate
+ # replies through the deterministic same-family surface TTS instead of a
+ # native readback, keeping one voice for the whole call.
+ renders_pinned_voice = False
def __init__(
self,
diff --git a/jarvis/realtime/protocol.py b/jarvis/realtime/protocol.py
index 2d7c5c7290..2e51556213 100644
--- a/jarvis/realtime/protocol.py
+++ b/jarvis/realtime/protocol.py
@@ -92,6 +92,14 @@ class RealtimeSession(Protocol):
The orchestrator calls it with the current bounded call transcript after
every completed turn so a provider-internal transport rebuild (e.g. the
openai_realtime BUG-064 stack) can restore context without a wire call.
+
+ Optional voice-identity capability (probed with ``getattr``, default
+ True when absent): ``renders_pinned_voice: bool``. A session whose
+ native audio generation is a fixed-voice synthesizer that reliably
+ speaks the requested voice keeps the default. A GENERATIVE renderer
+ that can audibly drift from the pinned voice mid-call (BUG-086)
+ declares False; the orchestrator then renders trusted delegate replies
+ through the deterministic surface TTS instead of a native readback.
"""
session_id: str
diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.py
index eb27644c98..c9c43b95f7 100644
--- a/jarvis/realtime/session.py
+++ b/jarvis/realtime/session.py
@@ -4345,7 +4345,22 @@ class RealtimeVoiceSession:
answer twice.
"""
turn_state.readback_verification_active = True
- deadline = time.monotonic() + _DELEGATE_READBACK_WAIT_S
+ # Voice-identity escalation (BUG-086): a provider session whose native
+ # audio is a GENERATIVE renderer (renders_pinned_voice=False) can
+ # audibly drift from the pinned session voice exactly on these
+ # injected readbacks — the longest, most performance-cue-laden texts
+ # of a call. On the desktop surface the same-family surface TTS speaks
+ # the trusted reply deterministically instead, so every deep reply
+ # keeps the one configured voice for the whole call. The browser
+ # surface keeps the native readback: it has no server-side rendering
+ # for ``error_spoken``, and its Web-Speech fallback would introduce a
+ # THIRD voice — the exact defect this path exists to prevent.
+ surface_owns_readback = self._surface == "desktop" and not bool(
+ getattr(self._session, "renders_pinned_voice", True)
+ )
+ deadline = time.monotonic() + (
+ 0.0 if surface_owns_readback else _DELEGATE_READBACK_WAIT_S
+ )
while True:
if (
self._ended
@@ -4370,13 +4385,21 @@ class RealtimeVoiceSession:
return
turn_state.surface_fallback_spoken = True
self._drop_provider_output_until_user_turn = True
- log.warning(
- "realtime[%s] provider rendered no readback for a delivered "
- "delegate result within %.1fs; speaking it through the surface "
- "TTS fallback",
- self.session_id,
- _DELEGATE_READBACK_WAIT_S,
- )
+ if surface_owns_readback:
+ log.info(
+ "realtime[%s] voice identity: speaking the delegate reply "
+ "through the surface TTS because the provider's native "
+ "renderer does not hold the pinned voice (BUG-086)",
+ self.session_id,
+ )
+ else:
+ log.warning(
+ "realtime[%s] provider rendered no readback for a delivered "
+ "delegate result within %.1fs; speaking it through the "
+ "surface TTS fallback",
+ self.session_id,
+ _DELEGATE_READBACK_WAIT_S,
+ )
await self._send_json(self._surface_speech_message(reply))
def _start_delegate(
diff --git a/tests/unit/realtime/test_session.py b/tests/unit/realtime/test_session.py
index 31e3a18037..010c4ccaea 100644
--- a/tests/unit/realtime/test_session.py
+++ b/tests/unit/realtime/test_session.py
@@ -2211,6 +2211,123 @@ async def test_scrub_trip_during_delegate_readback_speaks_trusted_reply():
assert binaries == []
+class _GenerativeVoiceSession(FakeSession):
+ """A provider session whose native audio renderer cannot hold a pinned
+ voice (BUG-086: Gemini Live's generative audio drifts on readbacks)."""
+
+ renders_pinned_voice = False
+
+ def __init__(self, events):
+ super().__init__(events)
+ self.release = asyncio.Event()
+ self._text_sent = asyncio.Event()
+
+ async def receive(self):
+ yield RealtimeEvent(
+ type="input_transcript",
+ text="What is in my Gmail inbox?",
+ is_final=True,
+ )
+ await self._text_sent.wait()
+ for event in self._events:
+ yield event
+ await asyncio.sleep(0)
+ # Keep the duplex stream open so the test controls session teardown.
+ await self.release.wait()
+
+ async def send_text(self, text):
+ await super().send_text(text)
+ self._text_sent.set()
+
+
+class _GenerativeVoiceProvider(FakeProvider):
+ async def open_session(self, cfg):
+ self.opened_with = cfg
+ self.session = _GenerativeVoiceSession(self._events)
+ return self.session
+
+
+async def test_generative_voice_provider_delegate_reply_is_spoken_by_the_surface():
+ """Voice identity (BUG-086 escalation): with renders_pinned_voice=False
+ the desktop surface speaks the delegate reply itself, immediately —
+ never waiting out the no-readback window and never letting the
+ provider's generative renderer re-voice the deep answer.
+ """
+ reply = "The deep answer that must keep the pinned voice."
+ jsons: list[dict] = []
+ binaries: list[bytes] = []
+ provider = _GenerativeVoiceProvider([])
+ sess = RealtimeVoiceSession(
+ session_id="generative-voice-surface-readback",
+ send_binary=lambda data: binaries.append(data) or asyncio.sleep(0),
+ send_json=lambda m: jsons.append(m) or asyncio.sleep(0),
+ provider=provider,
+ config=_delegate_cfg("delegate"),
+ brain=FakeBrain(replies=(reply,)),
+ surface="desktop",
+ )
+
+ await sess.handle_control({"type": "audio_start", "sample_rate": 16_000})
+
+ async def _spoken():
+ while not any(m.get("type") == "error_spoken" for m in jsons):
+ await asyncio.sleep(0.01)
+
+ # Well inside _DELEGATE_READBACK_WAIT_S (2.5 s): this is the immediate
+ # voice-identity path, not the old provider-mute timeout fallback.
+ await asyncio.wait_for(_spoken(), timeout=1.5)
+ spoken = [m for m in jsons if m.get("type") == "error_spoken"]
+ assert [m["text"] for m in spoken] == [reply]
+ # The provider still received the trusted result as conversation context.
+ assert provider.session.text_inputs, "trusted result was never injected"
+ # No native readback audio reached the speakers.
+ assert binaries == []
+ provider.session.release.set()
+ await sess.end(reason="test")
+
+
+async def test_generative_voice_provider_keeps_native_readback_on_the_browser_surface():
+ """The browser surface has no server-side TTS for error_spoken, so a
+ generative-voice provider still reads the delegate reply back natively
+ there — silence would be worse than a possible voice drift.
+ """
+ reply = "The browser hears the native readback."
+ spoken_audio = AudioChunk(
+ pcm=b"\x01\x02" * 8, sample_rate=24_000, timestamp_ns=0
+ )
+ jsons: list[dict] = []
+ binaries: list[bytes] = []
+ provider = _GenerativeVoiceProvider(
+ [
+ RealtimeEvent(
+ type="output_transcript_delta", text=reply, is_final=True
+ ),
+ RealtimeEvent(type="audio_delta", audio=spoken_audio),
+ RealtimeEvent(type="turn_complete"),
+ ]
+ )
+ sess = _session(
+ provider,
+ brain=FakeBrain(replies=(reply,)),
+ jsons=jsons,
+ binaries=binaries,
+ )
+
+ await sess.handle_control({"type": "audio_start", "sample_rate": 16_000})
+
+ async def _played():
+ while not binaries:
+ await asyncio.sleep(0.01)
+
+ await asyncio.wait_for(_played(), timeout=5)
+ assert binaries == [spoken_audio.pcm]
+ assert not any(m.get("type") == "error_spoken" for m in jsons)
+ provider.session.release.set()
+ await sess.end(reason="test")
+
+
class _ConfirmAwaitingBrain(FakeBrain):
"""FakeBrain that reports a pending two-turn voice confirmation."""