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(tts): the emergency voice keeps streaming when the quota blocks it

Personal Jarvis Maintainerdb650d727422
diff --git a/docs/BUGS.md b/docs/BUGS.md
index b79724d067..e37b21c63c 100644
--- a/docs/BUGS.md
+++ b/docs/BUGS.md
@@ -8875,3 +8875,86 @@ to) · `paneSocket.test.ts` "geometry reconciliation" (the frame reaches
holding an assumption, not a measurement. Any wire that lets one side clamp or
refuse needs a path back, or the two sides drift silently and the damage surfaces
somewhere that looks unrelated — here, as a rendering fault on one OS.
+
+## BUG-129: Jarvis speaks three words, then goes silent for the rest of the answer — the emergency voice is one blocking whole-answer take (HIGH, FIXED 2026-08-11)
+
+**Symptom (maintainer field report, voice session 2026-08-11 21:26, realtime).**
+Asked on camera to explain what it can do, Jarvis started the answer, spoke
+roughly three words, and stopped. Nothing else was ever heard. The session
+transcript showed a complete, well-formed answer — so the recording claims
+Jarvis delivered a paragraph the user never heard, and the only honest reading
+from the chair is "it broke mid-sentence".
+
+**What the log actually shows** (session `88eb1137`, `provider=gemini-live`,
+tool mode `delegate`):
+
+| time | event |
+|---|---|
+| 21:26:56.679 | `RT-SPAWN span=first_audio ms=8145` — the live model starts speaking its own answer |
+| 21:26:56.842 | `OutputStream opened @ 24000 Hz (… actual_latency=1.542s)` |
+| 21:26:59.713 | `blocked an action promise with no execution evidence` |
+| 21:26:59.787 | `withholding provider audio … awaiting a new response after a barge-in or delegation` |
+| 21:27:01.063 | the router brain (grok) returns the grounded answer — **this is the text in the transcript** |
+| 21:27:04.786 | `provider produced no audio for a grounded Brain result; using surface TTS fallback` |
+| 21:27:05.301 | `Gemini-TTS stream quota-blocked on gemini-3.1-flash-tts-preview (retry in 1 min)` |
+| 21:27:05.302 | `stream failed before first audio — blocking fallback will synthesize this sentence` |
+| 21:27:20.731 | `request_hangup` — the user gives up after **15.4 s of silence** |
+| 21:27:41.345 | the blocking `gemini-2.5-flash-preview-tts` POST returns 200 — **36.0 s** after it started, 20.6 s after the session was gone |
+
+Three of those lines are working as designed. The provider promised
+capabilities it had not exercised, the action-promise guard blocked the
+rendering 2.9 s in and delegated to the Brain, and the Brain produced a
+grounded answer. With a 1.542 s output latency, 2.9 s of sent frames is about
+1.4 s of *audible* speech — the three words. Everything after that point was
+supposed to arrive through the surface TTS fallback.
+
+**Root cause.** The realtime surface fallback is built with
+`chunk_by_sentence=False` on purpose: one whole-answer generation is what keeps
+the session's voice identity intact (BUG-090). That is only survivable because
+the transport is meant to stream — `build_realtime_surface_tts` says so in a
+comment. But `_synthesize_stream_one` streamed from `self._model_name` and
+nothing else: it had **no sibling-bridge rung**, while the blocking ladder in
+`_synthesize_one` has had one since 2026-05-14. So a `RESOURCE_EXHAUSTED` on
+the primary model ended streaming for that text outright, and the one-take
+design fell through to a single blocking `generate_content` — 36 s for a
+1000-character answer, with nothing audible until the very end.
+
+Two multipliers made it worse than a one-turn accident. The cooldown the 429
+arms runs up to an hour, and the old code returned from the stream immediately
+while it was armed — so *every* following turn took the same blocking take, not
+just the one that tripped the quota. And `streaming` was inherited from the
+pipeline's `[tts]` knob, so an install that had turned pipeline streaming off
+was in this state permanently, with no quota involved at all.
+
+**Fix.** `jarvis/plugins/tts/gemini_flash_tts.py` — `_stream_model_ladder()`
+mirrors the blocking ladder exactly (primary first, sibling only while the
+primary is quota-blocked, each rung skipped while its own cooldown is armed),
+and `_synthesize_stream_one` walks it, delegating one generation per rung to
+`_stream_one_model`. A 429 now bridges to the sibling **on the streaming
+transport**, so the answer keeps a sub-second time-to-first-audio in exactly
+the case that produced the silence. It reaches the same model the blocking
+ladder would have used, so no new voice is introduced, and the bridge
+announcement is now shared by both transports (`_announce_sibling_bridge`) so
+it stays once-per-process. A non-quota error still does NOT bridge — it falls
+to the blocking ladder, which retries the primary, so a transient blip cannot
+flip which model speaks. `jarvis/plugins/tts/__init__.py` pins `streaming=True`
+for the surface instance: it is the one-take design's precondition, not a
+preference to inherit.
+
+**Guards.** `tests/unit/plugins/tts/test_gemini_streaming.py` — a primary 429
+streams from the sibling and never reaches the blocking path; an already-armed
+cooldown starts on the sibling without calling the blocked primary at all; a
+sibling 429 arms its **own** timer; both cooldowns armed skips the network
+entirely; a transient error does not bridge and does not arm a cooldown.
+`test_realtime_surface_tts.py` — the surface instance streams even with
+`[tts].streaming = false`. Verified sharp: four of these fail against the
+previous implementation.
+
+**Class rule.** A fallback whose latency budget depends on a transport must own
+that transport, not inherit it — and every degradation ladder needs the same
+rungs on every transport that can walk it. Here the blocking path had a quota
+bridge and the streaming path did not, so a quota error silently demoted the
+answer from "streams in under a second" to "one 36-second generation", and the
+turn reported itself healthy the whole way down. When the last mile before the
+speaker can take that long, silence is indistinguishable from a crash to the
+only person who can tell you it broke.
diff --git a/jarvis/plugins/tts/__init__.py b/jarvis/plugins/tts/__init__.py
index 56c522dafd..525b073d8d 100644
--- a/jarvis/plugins/tts/__init__.py
+++ b/jarvis/plugins/tts/__init__.py
@@ -341,7 +341,16 @@ def build_realtime_surface_tts(cfg: Any, realtime_provider: str) -> Any | None:
allow_sapi5_fallback=bool(
getattr(tts_cfg, "allow_sapi5_fallback", False)
),
- streaming=bool(getattr(tts_cfg, "streaming", False)),
+ # Streaming is this instance's PRECONDITION, not a preference
+ # inherited from [tts]: one whole-answer take (below) only has
+ # an acceptable time-to-first-audio while the transport hands
+ # the PCM out during generation. Blocking, a 1000-character
+ # answer is a single 36 s generation with nothing audible
+ # until the very end (live forensic 2026-08-11 21:27 — the
+ # user hung up 15 s before the audio existed). A pipeline
+ # knob turned off for the pipeline's own reasons must never
+ # convert the emergency voice into dead air.
+ streaming=True,
# Voice-identity profile (BUG-090). Gemini TTS is generative:
# every generation re-rolls the delivery, and a performance cue
# in the text (dialect persona, quoted lines) can flip the
@@ -350,10 +359,9 @@ def build_realtime_surface_tts(cfg: Any, realtime_provider: str) -> Any | None:
# fallback one generation PER SENTENCE — the second take came
# out as a different-gender voice mid-answer. The emergency
# re-render exists solely to keep the session's voice identity,
- # so it is always ONE take (with streaming=True the single
- # whole-text generation still streams, no first-audio cost)
- # and inherits the [tts] drift knobs the pipeline instance
- # already honors.
+ # so it is always ONE take — which the pinned streaming above
+ # keeps cheap to start — and inherits the [tts] drift knobs
+ # the pipeline instance already honors.
chunk_by_sentence=False,
seed=getattr(tts_cfg, "seed", None),
temperature=getattr(tts_cfg, "temperature", None),
diff --git a/jarvis/plugins/tts/gemini_flash_tts.py b/jarvis/plugins/tts/gemini_flash_tts.py
index 49ee8f2234..5bae58cb56 100644
--- a/jarvis/plugins/tts/gemini_flash_tts.py
+++ b/jarvis/plugins/tts/gemini_flash_tts.py
@@ -24,7 +24,7 @@ import contextlib
import logging
import re
import time
-from collections.abc import AsyncIterator
+from collections.abc import AsyncGenerator, AsyncIterator
from typing import Any
from jarvis.core import config as cfg
@@ -548,16 +548,47 @@ class GeminiFlashTTS:
)
return b""
- if pcm and not self._sibling_bridge_announced:
- self._sibling_bridge_announced = True
- log.warning(
- "Gemini TTS sibling bridge active: primary=%s throttled → speaking "
- "via %s. Voice (%s) is language-agnostic and identical. As soon as the "
- "primary quota reopens, the code switches back automatically.",
- self._model_name, self._sibling_bridge_model, voice,
- )
+ if pcm:
+ self._announce_sibling_bridge(voice, self._sibling_bridge_model)
return pcm
+ def _announce_sibling_bridge(self, voice: str, model: str) -> None:
+ """Log the bridge switch exactly once, whichever transport took it.
+
+ Shared by the blocking ladder and the streaming ladder: both rungs
+ end on the SAME sibling model, so the user must see the model change
+ once per process — not once per transport.
+ """
+ if self._sibling_bridge_announced:
+ return
+ self._sibling_bridge_announced = True
+ logging.getLogger("jarvis.tts").warning(
+ "Gemini TTS sibling bridge active: primary=%s throttled → speaking "
+ "via %s. Voice (%s) is language-agnostic and identical. As soon as the "
+ "primary quota reopens, the code switches back automatically.",
+ self._model_name, model, voice,
+ )
+
+ def _stream_model_ladder(self) -> list[tuple[str, bool]]:
+ """Which models the streaming transport may try, in order.
+
+ Mirrors ``_synthesize_one``'s blocking ladder exactly — primary
+ first, sibling bridge only while the primary is quota-blocked — so a
+ 429 never changes WHICH model speaks depending on which transport
+ happened to run. A model whose own cooldown is armed is skipped, and
+ an empty ladder simply yields no audio (the blocking path then
+ returns its own silence receipt).
+ """
+ now = time.monotonic()
+ ladder: list[tuple[str, bool]] = []
+ if not (self._quota_blocked_until and now < self._quota_blocked_until):
+ ladder.append((self._model_name, False))
+ if self._sibling_bridge_model and not (
+ self._sibling_blocked_until and now < self._sibling_blocked_until
+ ):
+ ladder.append((self._sibling_bridge_model, True))
+ return ladder
+
async def _synthesize_stream_one(
self, text: str, voice: str, language_code: str | None = None
) -> AsyncIterator[bytes]:
@@ -568,24 +599,96 @@ class GeminiFlashTTS:
only the transport differs: ``generate_content_stream`` hands out the
audio while the model is still generating.
+ The ladder carries the SIBLING BRIDGE too (live forensic 2026-08-11
+ 21:27): a quota block on the primary used to end streaming for this
+ sentence outright, and the surface fallback — one whole-answer take
+ by construction (``chunk_by_sentence=False``) — then went out as a
+ single blocking generation that took 36 s for a 1000-character
+ answer. The user heard nothing and hung up 15 s before the audio
+ existed. Bridging to the sibling while STAYING on the streaming
+ transport keeps time-to-first-audio sub-second in exactly the case
+ that produced the silence; it speaks through the same model the
+ blocking ladder would have reached, so no new voice is introduced.
+
Failure contract (composes with the blocking ladder + FallbackTTS):
- * primary quota-cooldown active → yield nothing; the caller falls
- back to ``_synthesize_one`` (which routes to the sibling bridge).
- * stream fails BEFORE the first audio byte → yield nothing (caller
- falls back, zero audio lost).
+ * every ladder rung cooled down → yield nothing; the caller falls
+ back to ``_synthesize_one`` (which reports the silence).
+ * rung 429s BEFORE the first audio byte → arm that model's cooldown
+ and try the next rung, still streaming.
+ * a rung fails otherwise before the first audio byte → yield
+ nothing (caller falls back to blocking, zero audio lost); the
+ sibling is NOT tried, so a transient blip keeps the primary voice.
* stream fails AFTER audio was yielded → stop with the partial
audio; never re-synthesize (would replay the opening words).
- * RESOURCE_EXHAUSTED arms the same ``_quota_blocked_until`` cooldown
- the blocking path maintains.
"""
log = logging.getLogger("jarvis.tts")
- if self._quota_blocked_until and time.monotonic() < self._quota_blocked_until:
- return
- produced = False
+ for model, is_sibling in self._stream_model_ladder():
+ outcome: dict[str, Any] = {}
+ pieces = self._stream_one_model(
+ text, voice, model, is_sibling, language_code, outcome
+ )
+ try:
+ async for piece in pieces:
+ yield piece
+ finally:
+ # ``async for`` never closes its iterator (PEP 525); on a
+ # barge-in the GeneratorExit lands on the yield above and
+ # this is the only deterministic release of the inner
+ # generator's genai HTTP stream.
+ with contextlib.suppress(Exception):
+ await pieces.aclose()
+ exc = outcome.get("error")
+ if outcome.get("produced"):
+ if is_sibling:
+ self._announce_sibling_bridge(voice, model)
+ if exc is not None:
+ log.warning(
+ "Gemini-TTS stream broke mid-sentence (%s) — keeping the "
+ "partial audio, not re-synthesizing.",
+ exc.__class__.__name__,
+ )
+ return
+ if exc is None:
+ # A clean stream that carried no audio (safety filter, empty
+ # candidates). The next rung would meet the same content, so
+ # hand the sentence to the blocking ladder unchanged.
+ return
+ if not outcome.get("quota"):
+ log.warning(
+ "Gemini-TTS stream failed before first audio (%s) — blocking "
+ "fallback will synthesize this sentence.",
+ exc.__class__.__name__,
+ )
+ return
+
+ async def _stream_one_model(
+ self,
+ text: str,
+ voice: str,
+ model: str,
+ is_sibling: bool,
+ language_code: str | None,
+ outcome: dict[str, Any],
+ ) -> AsyncGenerator[bytes, None]:
+ """Stream ONE generation from ONE model and report why it stopped.
+
+ Typed as a generator, not a bare ``AsyncIterator``: the caller's
+ barge-in path closes it explicitly, and ``aclose`` is the whole
+ reason this layer is deterministic about the genai HTTP stream.
+
+ An async generator cannot return a value, so ``outcome`` is filled in
+ place: ``produced`` says whether any PCM was yielded, ``error`` holds
+ the exception that ended the stream, and ``quota`` marks it as a
+ RESOURCE_EXHAUSTED on ``model``. Arming the cooldown stays here,
+ where the model that actually 429'd is unambiguous.
+ """
+ log = logging.getLogger("jarvis.tts")
+ outcome["produced"] = False
+ outcome["quota"] = False
stream = None
try:
stream = await self._client.aio.models.generate_content_stream(
- model=self._model_name,
+ model=model,
contents=text,
config=self._build_config(voice, language_code),
)
@@ -595,31 +698,24 @@ class GeminiFlashTTS:
for part in (content.parts if content else None) or []:
data = part.inline_data.data if part.inline_data else None
if data:
- produced = True
+ outcome["produced"] = True
yield data
except asyncio.CancelledError:
raise
- except Exception as exc: # noqa: BLE001 — degrade to the blocking ladder
+ except Exception as exc: # noqa: BLE001 — degrade to the next rung
+ outcome["error"] = exc
msg = str(exc)
if "RESOURCE_EXHAUSTED" in msg or "429" in msg:
+ outcome["quota"] = True
retry_s = _parse_retry_delay(msg)
- self._quota_blocked_until = time.monotonic() + retry_s
+ if is_sibling:
+ self._sibling_blocked_until = time.monotonic() + retry_s
+ else:
+ self._quota_blocked_until = time.monotonic() + retry_s
log.warning(
"Gemini-TTS stream quota-blocked on %s (retry in %.0f min).",
- self._model_name, retry_s / 60,
+ model, retry_s / 60,
)
- if produced:
- log.warning(
- "Gemini-TTS stream broke mid-sentence (%s) — keeping the "
- "partial audio, not re-synthesizing.",
- exc.__class__.__name__,
- )
- return
- log.warning(
- "Gemini-TTS stream failed before first audio (%s) — blocking "
- "fallback will synthesize this sentence.",
- exc.__class__.__name__,
- )
finally:
# GeneratorExit (barge-in) bypasses both except clauses above —
# this finally is the only deterministic release of the genai
diff --git a/tests/unit/plugins/tts/test_gemini_streaming.py b/tests/unit/plugins/tts/test_gemini_streaming.py
index 3af46f3797..a823b41af3 100644
--- a/tests/unit/plugins/tts/test_gemini_streaming.py
+++ b/tests/unit/plugins/tts/test_gemini_streaming.py
@@ -22,6 +22,7 @@ Contract pinned here:
"""
from __future__ import annotations
+import time
from dataclasses import dataclass, field
from types import SimpleNamespace
from typing import Any
@@ -214,6 +215,166 @@ async def test_streaming_closes_provider_stream_on_early_exit() -> None:
)
+# ---------------------------------------------------------------------------
+# Streaming ladder: a quota block must not demote the answer to a blocking
+# whole-text generation (live forensic 2026-08-11 21:27).
+# ---------------------------------------------------------------------------
+
+_SIBLING = "gemini-2.5-flash-preview-tts"
+_PRIMARY = "gemini-3.1-flash-tts-preview"
+
+
+@dataclass
+class _FakeAioModelsPerModel:
+ """``client.aio.models`` fake whose behaviour depends on the model asked for."""
+
+ pieces_by_model: dict[str, list[bytes]] = field(default_factory=dict)
+ raise_by_model: dict[str, Exception] = field(default_factory=dict)
+ calls: list[str] = field(default_factory=list)
+
+ async def generate_content_stream(
+ self, *, model: str, contents: str, config: Any
+ ) -> Any:
+ self.calls.append(model)
+ exc = self.raise_by_model.get(model)
+ if exc is not None:
+ raise exc
+ pieces = self.pieces_by_model.get(model, [])
+
+ async def _gen():
+ for piece in pieces:
+ yield _audio_chunk(piece)
+
+ return _gen()
+
+
+def _blocking_must_not_run(tts: GeminiFlashTTS, seen: list[str]) -> None:
+ """Pin the blocking path as a tripwire: reaching it is the regression."""
+
+ async def fake_one(text: str, voice: str, language_code: str | None = None) -> bytes:
+ seen.append(text)
+ return b"BLOCKING_WHOLE_TEXT"
+
+ tts._synthesize_one = fake_one # type: ignore[assignment]
+
+
+async def test_primary_quota_block_bridges_to_the_sibling_STREAM() -> None:
+ """The whole point: a 429 keeps the answer STREAMING.
+
+ Live forensic 2026-08-11 21:27 — the realtime surface fallback is one
+ whole-answer take by construction (``chunk_by_sentence=False``). When the
+ primary 429'd, the stream gave up and that single take went out as a
+ BLOCKING generation: 36 s for a 1000-character answer, nothing audible
+ until the very end, and the user hung up 15 s before the audio existed.
+ The sibling bridge must therefore exist on the streaming transport too,
+ not only on the blocking one.
+ """
+ aio = _FakeAioModelsPerModel(
+ raise_by_model={_PRIMARY: RuntimeError(_GOOGLE_429_MESSAGE)},
+ pieces_by_model={_SIBLING: [b"S1", b"S2", b"S3"]},
+ )
+ tts = _new_streaming_tts(aio)
+ blocking: list[str] = []
+ _blocking_must_not_run(tts, blocking)
+
+ pcm = await _collect_pcm(tts, "Ein langer Satz ohne Satzzeichen dazwischen")
+
+ assert pcm == [b"S1", b"S2", b"S3"], "the sibling must stream, not buffer"
+ assert aio.calls == [_PRIMARY, _SIBLING]
+ assert blocking == [], "a quota block must never fall to a blocking whole-text take"
+ assert tts._quota_blocked_until > 0.0, "the primary cooldown is still armed"
+
+
+async def test_armed_primary_cooldown_starts_on_the_sibling_stream() -> None:
+ """Every FOLLOWING turn inside the cooldown streams too.
+
+ The cooldown runs up to an hour, so the turn that trips the 429 is not
+ the only victim: the old code returned from the stream immediately while
+ ``_quota_blocked_until`` was armed, handing every later turn the same
+ blocking whole-text take.
+ """
+ aio = _FakeAioModelsPerModel(pieces_by_model={_SIBLING: [b"S1"]})
+ tts = _new_streaming_tts(aio)
+ tts._quota_blocked_until = time.monotonic() + 3600.0
+ blocking: list[str] = []
+ _blocking_must_not_run(tts, blocking)
+
+ pcm = await _collect_pcm(tts, "Zweiter Satz im selben Cooldown")
+
+ assert pcm == [b"S1"]
+ assert aio.calls == [_SIBLING], "the blocked primary must not be called at all"
+ assert blocking == []
+
+
+async def test_sibling_429_arms_its_own_cooldown_then_hands_over() -> None:
+ """Both rungs exhausted → the blocking path owns the outcome, fast."""
+ aio = _FakeAioModelsPerModel(
+ raise_by_model={
+ _PRIMARY: RuntimeError(_GOOGLE_429_MESSAGE),
+ _SIBLING: RuntimeError(_GOOGLE_429_MESSAGE),
+ }
+ )
+ tts = _new_streaming_tts(aio)
+
+ async def fake_one(text: str, voice: str, language_code: str | None = None) -> bytes:
+ return b""
+
+ tts._synthesize_one = fake_one # type: ignore[assignment]
+
+ pcm = await _collect_pcm(tts, "Ein kurzer Satz.")
+
+ assert pcm == []
+ assert aio.calls == [_PRIMARY, _SIBLING]
+ assert tts._quota_blocked_until > 0.0
+ assert tts._sibling_blocked_until > 0.0, "the sibling 429 must arm its OWN timer"
+
+
+async def test_both_cooldowns_armed_skips_the_stream_entirely() -> None:
+ """No pointless API call against two models that are known to be blocked."""
+ aio = _FakeAioModelsPerModel()
+ tts = _new_streaming_tts(aio)
+ tts._quota_blocked_until = time.monotonic() + 3600.0
+ tts._sibling_blocked_until = time.monotonic() + 3600.0
+
+ async def fake_one(text: str, voice: str, language_code: str | None = None) -> bytes:
+ return b"BLOCKING_SILENCE_RECEIPT"
+
+ tts._synthesize_one = fake_one # type: ignore[assignment]
+
+ pcm = await _collect_pcm(tts, "Ein kurzer Satz.")
+
+ assert pcm == [b"BLOCKING_SILENCE_RECEIPT"]
+ assert aio.calls == []
+
+
+async def test_transient_stream_error_does_not_bridge_to_the_sibling() -> None:
+ """Voice continuity: only a QUOTA block changes which model speaks.
+
+ A network blip must keep the primary voice by falling to the blocking
+ ladder (which retries the primary), exactly as ``_synthesize_one`` does.
+ Bridging on any error would flip the model on every transient failure.
+ """
+ aio = _FakeAioModelsPerModel(
+ raise_by_model={_PRIMARY: RuntimeError("transport exploded")},
+ pieces_by_model={_SIBLING: [b"MUST_NOT_APPEAR"]},
+ )
+ tts = _new_streaming_tts(aio)
+ blocking: list[str] = []
+ _blocking_must_not_run(tts, blocking)
+
+ pcm = await _collect_pcm(tts, "Ein kurzer Satz.")
+
+ assert pcm == [b"BLOCKING_WHOLE_TEXT"]
+ assert aio.calls == [_PRIMARY], "a transient error must not reach the sibling"
+ assert blocking == ["Ein kurzer Satz."]
+ assert tts._quota_blocked_until == 0.0, "a non-429 must not arm the cooldown"
+
+
def test_factory_wires_tts_streaming_flag() -> None:
"""``[tts].streaming = true`` must reach the provider (the key existed in
jarvis.toml but was never forwarded — dead config)."""
diff --git a/tests/unit/plugins/tts/test_realtime_surface_tts.py b/tests/unit/plugins/tts/test_realtime_surface_tts.py
index 04292db4e9..b320ec228b 100644
--- a/tests/unit/plugins/tts/test_realtime_surface_tts.py
+++ b/tests/unit/plugins/tts/test_realtime_surface_tts.py
@@ -126,6 +126,29 @@ def test_surface_fallback_is_one_take_even_without_configured_knobs() -> None:
assert tts._temperature is None
+def test_surface_fallback_always_streams_whatever_the_pipeline_knob_says() -> None:
+ """One whole-answer take is only safe while the transport streams it.
+
+ Live forensic 2026-08-11 21:27: the emergency re-render of a
+ 1000-character answer went out as a single BLOCKING generation and took
+ 36 s — the user heard nothing and hung up 15 s before the audio existed.
+ ``chunk_by_sentence=False`` (voice identity) and blocking synthesis
+ (first audio == whole generation) are only compatible via streaming, so
+ streaming is this instance's precondition, not an inherited preference:
+ ``_cfg()`` deliberately carries ``[tts].streaming = False``.
+ """
+ cfg = _cfg()
+ assert cfg.tts.streaming is False, "fixture must model the pipeline knob OFF"
+ with override_provider_secrets({"gemini-live": "rt-scoped-key"}):
+ tts = build_realtime_surface_tts(cfg, "gemini-live")
+ assert isinstance(tts, GeminiFlashTTS)
+ assert tts._streaming is True, (
+ "a pipeline knob turned off must never convert the emergency voice "
+ "into a blocking whole-answer take"
+ )
+ assert tts._chunk_by_sentence is False
+
+
def test_keyless_realtime_provider_yields_no_surface_tts() -> None:
with override_provider_secrets({"gemini-live": None}):
assert build_realtime_surface_tts(_cfg(), "gemini-live") is None