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): make Realtime provider model + voice selectable
Ruben Lütkebe8f7ddc3d13
diff --git a/jarvis/brain/model_catalog.py b/jarvis/brain/model_catalog.pyindex c16dcf047c..a46060cdb0 100644--- a/jarvis/brain/model_catalog.py+++ b/jarvis/brain/model_catalog.py@@ -224,6 +224,67 @@ TTS_CATALOG: dict[str, tuple[str, list[ModelInfo]]] = {])),}+# Realtime catalogs — REALTIME_MODELS + REALTIME_VOICES, keyed by realtime+# provider id (``openai-realtime`` / ``gemini-live``). Realtime needs BOTH a+# model AND a voice selection per provider (unlike every other picker, which+# serves ONE selection), so these two dicts are looked up directly by the+# dedicated ``GET/PUT /providers/{id}/realtime-options`` endpoints rather than+# being registered into ``PROVIDER_CATALOG``/``catalog_spec`` (that machinery+# is built around a single ``selects: "model" | "voice"`` per provider).+# Curated, not live-fetched: no realtime provider exposes a ``/v1/models``+# endpoint reachable the same way as the text-brain catalogs, and a curated+# list is realtime-only by construction (never leaks a non-realtime model into+# the picker). The currently-hardcoded adapter default is always FIRST in each+# model list — the safe fallback an unset pick resolves to.+#+# openai-realtime — verified 2026-07-08 against+# developers.openai.com/api/docs/models/all (cross-checked against the+# installed ``openai`` SDK's beta realtime session ``model`` Literal, which+# lists the same gpt-realtime family). ``gpt-realtime`` is OpenAI's current GA+# default (matches ``_MODEL`` in ``jarvis/plugins/realtime/openai_realtime.py``);+# ``gpt-realtime-2.1``/``-2.1-mini`` are the newest reasoning-capable siblings+# (released 2026-07-06); ``gpt-realtime-mini`` is the established cost-efficient+# sibling. ``gpt-realtime-translate``/``gpt-realtime-whisper`` are deliberately+# excluded — single-purpose speech-translation / transcription models, not+# general duplex voice-agent models this adapter's protocol targets.+REALTIME_MODELS: dict[str, list[ModelInfo]] = {+ "openai-realtime": _curated([+ ("gpt-realtime", "GPT Realtime (default)"),+ ("gpt-realtime-2.1", "GPT Realtime 2.1"),+ ("gpt-realtime-2.1-mini", "GPT Realtime 2.1 Mini"),+ ("gpt-realtime-mini", "GPT Realtime Mini"),+ ]),+ # gemini-live — verified 2026-07-08 against ai.google.dev/gemini-api/docs/models+ # (the Live API model list). ``gemini-3.1-flash-live-preview`` is the current+ # flagship (matches ``_MODEL`` in ``jarvis/plugins/realtime/gemini_live.py``);+ # ``gemini-2.5-flash-native-audio-preview-12-2025`` is the current 2.5-series+ # native-audio sibling still listed on that page. The older+ # ``gemini-2.0-flash-live-preview`` family is marked for shutdown — omitted.+ "gemini-live": _curated([+ ("gemini-3.1-flash-live-preview", "Gemini 3.1 Flash Live (default)"),+ (+ "gemini-2.5-flash-native-audio-preview-12-2025",+ "Gemini 2.5 Flash Native Audio",+ ),+ ]),+}++# Realtime voice catalogs — stable prebuilt-voice names (curated, not live).+# openai-realtime: verified 2026-07-08 against the installed ``openai`` SDK's+# beta realtime session ``voice`` Literal — the 8 GA prebuilt voices.+# gemini-live: verified 2026-07-08 — the 8 prebuilt voices exposed to+# ``types.PrebuiltVoiceConfig.voice_name`` for the Live API's half-cascade /+# native-audio models (a strict subset of the ~30-voice Gemini TTS catalog).+REALTIME_VOICES: dict[str, list[ModelInfo]] = {+ "openai-realtime": _ids([+ "alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse",+ ]),+ "gemini-live": _ids([+ "Puck", "Charon", "Kore", "Fenrir", "Aoede", "Orus", "Leda", "Zephyr",+ ]),+}++# STT model catalogs (the ``[stt] model`` is a single global value).STT_CATALOG: dict[str, list[ModelInfo]] = {"groq-api": _ids(["whisper-large-v3", "whisper-large-v3-turbo", "distil-whisper-large-v3-en"]),diff --git a/jarvis/plugins/realtime/gemini_live.py b/jarvis/plugins/realtime/gemini_live.pyindex 1a9fd00669..aecf8983c1 100644--- a/jarvis/plugins/realtime/gemini_live.py+++ b/jarvis/plugins/realtime/gemini_live.py@@ -31,10 +31,17 @@ fields/methods used here are stable across all three, re-checked 2026-07-08):``turn_complete`` (both transcription fields are ``Transcription`` objectswith a ``.text`` field) — exactly the shape this module maps below.- ``types.LiveConnectConfig`` has ``response_modalities``,- ``system_instruction``, ``input_audio_transcription`` and- ``output_audio_transcription`` (both ``AudioTranscriptionConfig``) among- its fields — transcripts are OFF by default and MUST be requested via the- latter two, or ``server_content`` never carries a transcription.+ ``system_instruction``, ``input_audio_transcription``,+ ``output_audio_transcription`` (both ``AudioTranscriptionConfig``) and+ ``speech_config`` (a ``types.SpeechConfig``) among its fields — transcripts+ are OFF by default and MUST be requested via the two transcription fields,+ or ``server_content`` never carries a transcription.+- ``types.SpeechConfig.voice_config`` is a ``types.VoiceConfig`` whose+ ``prebuilt_voice_config`` is a ``types.PrebuiltVoiceConfig(voice_name=...)``+ — introspected against the installed 2.9.0 SDK 2026-07-08+ (``types.PrebuiltVoiceConfig.model_fields`` == ``{"voice_name"}``); selects+ one of the Live API's 8 prebuilt voices (Puck/Charon/Kore/Fenrir/Aoede/Orus/+ Leda/Zephyr).Model id: ``gemini-3.1-flash-live-preview``, confirmed live onhttps://ai.google.dev/gemini-api/docs/live-api/get-started-sdk (fetched@@ -146,8 +153,24 @@ class GeminiLiveProvider:system_instruction=cfg.instructions or None,input_audio_transcription=types.AudioTranscriptionConfig(),output_audio_transcription=types.AudioTranscriptionConfig(),+ # A pinned voice picks one of the Live API's 8 prebuilt voices+ # (Puck/Charon/Kore/...). Omitted entirely when unset so the+ # provider keeps its own default (today's behavior, no regression).+ **(+ {+ "speech_config": types.SpeechConfig(+ voice_config=types.VoiceConfig(+ prebuilt_voice_config=types.PrebuiltVoiceConfig(+ voice_name=cfg.voice+ )+ )+ )+ }+ if cfg.voice+ else {}+ ),)- cm = client.aio.live.connect(model=_MODEL, config=live_config)+ cm = client.aio.live.connect(model=cfg.model or _MODEL, config=live_config)session = await cm.__aenter__()import uuiddiff --git a/jarvis/plugins/realtime/openai_realtime.py b/jarvis/plugins/realtime/openai_realtime.pyindex eb150276c5..60ddb06b10 100644--- a/jarvis/plugins/realtime/openai_realtime.py+++ b/jarvis/plugins/realtime/openai_realtime.py@@ -91,7 +91,7 @@ class OpenAIRealtimeProvider:from openai import AsyncOpenAI # lazy (AP-26)client = AsyncOpenAI(api_key=get_provider_secret("openai"))- conn = await client.realtime.connect(model=_MODEL).__aenter__()+ conn = await client.realtime.connect(model=cfg.model or _MODEL).__aenter__()session_payload: dict[str, Any] = {"instructions": cfg.instructions,"output_modalities": list(cfg.modalities),diff --git a/jarvis/realtime/protocol.py b/jarvis/realtime/protocol.pyindex eb012c5e43..201a205560 100644--- a/jarvis/realtime/protocol.py+++ b/jarvis/realtime/protocol.py@@ -43,6 +43,8 @@ class RealtimeSessionConfig:instructions: str = ""language: str = "en" # bare de/en/es (resolved once, upstream)+ model: str = "" # provider model id ("" -> the adapter's+ # hardcoded default; no regression)voice: str = ""input_sample_rate: int = 16000output_sample_rate: int = 24000diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.pyindex fddd4e8c0f..584f7d8f3d 100644--- a/jarvis/realtime/session.py+++ b/jarvis/realtime/session.py@@ -76,11 +76,27 @@ class RealtimeVoiceSession:elif kind == "audio_stop":await self.end(reason="client_stop")+ def _active_provider_selection(self) -> tuple[str, str]:+ """The active realtime provider's pinned model+voice from+ ``[brain.providers.<id>]`` ("" -> the adapter's own hardcoded default,+ no regression). ``<id>`` is the provider this session was built for+ (``self._provider.name``, e.g. "openai-realtime" / "gemini-live") —+ NOT a global voice setting, since model+voice are pinned per realtime+ provider (replaces the dead ``cfg.voice.realtime_voice`` read)."""+ provider_id = getattr(self._provider, "name", "") or ""+ providers = getattr(getattr(self._config, "brain", None), "providers", None)+ pc = providers.get(provider_id) if isinstance(providers, dict) else None+ model = (getattr(pc, "model", None) or "") if pc is not None else ""+ voice = (getattr(pc, "voice", None) or "") if pc is not None else ""+ return model, voice+async def _open(self) -> None:+ model, voice = self._active_provider_selection()cfg = RealtimeSessionConfig(instructions=_INSTRUCTIONS,language=self._language,- voice=getattr(getattr(self._config, "voice", None), "realtime_voice", "") or "",+ model=model,+ voice=voice,)self._session = await self._provider.open_session(cfg)self._pump_task = asyncio.create_task(self._pump(), name=f"rt-pump-{self.session_id}")diff --git a/jarvis/ui/web/provider_routes.py b/jarvis/ui/web/provider_routes.pyindex 9faa281e22..96bea536ad 100644--- a/jarvis/ui/web/provider_routes.py+++ b/jarvis/ui/web/provider_routes.py@@ -200,6 +200,38 @@ class CuModelResponse(BaseModel):restart_required: bool = False+# Realtime needs BOTH a model AND a voice per provider (unlike every other+# picker, which serves ONE selection) — a small dedicated control + endpoint+# rather than the search-heavy BrainModelSelector. Curated lists only+# (jarvis.brain.model_catalog.REALTIME_MODELS/REALTIME_VOICES), no live fetch.+class RealtimeOptionInfo(BaseModel):+ id: str+ label: str+++class RealtimeOptionsResponse(BaseModel):+ provider: str+ models: list[RealtimeOptionInfo]+ voices: list[RealtimeOptionInfo]+ current_model: str+ current_voice: str+++class RealtimeOptionsBody(BaseModel):+ # Omitted (None) -> leave unchanged; "" -> explicitly clear (provider+ # default), mirroring CuModelBody's "" contract.+ model: str | None = Field(default=None, max_length=200)+ voice: str | None = Field(default=None, max_length=100)+++class RealtimeOptionsSaveResponse(BaseModel):+ ok: bool = True+ provider: str+ model: str+ voice: str+ restart_required: bool = False++# ----------------------------------------------------------------------# Helper# ----------------------------------------------------------------------@@ -1369,6 +1401,130 @@ async def set_cu_model()+# ── GET/PUT /providers/{id}/realtime-options ───────────────────────────────+# Selectable Realtime model + voice, per realtime provider (openai-realtime /+# gemini-live). Realtime needs BOTH per provider, so this is a small dedicated+# endpoint rather than reusing GET/PUT /providers/{id}/model.+++def _require_realtime_provider(provider_id: str) -> ProviderSpec:+ """404 unknown id; 400 a non-realtime-tier id (mirrors /realtime/switch)."""+ spec = get_spec(provider_id)+ if spec is None:+ raise HTTPException(status_code=404, detail=f"Unbekannter Provider: {provider_id}")+ if spec.tier != "realtime":+ raise HTTPException(+ status_code=400,+ detail=f"Provider '{provider_id}' ist kein Realtime-Provider (tier={spec.tier})",+ )+ return spec+++def _current_realtime_selection(cfg: Any, provider_id: str) -> tuple[str, str]:+ """The (model, voice) currently pinned for ``provider_id`` in+ ``[brain.providers.<id>]`` ("" / "" when unset)."""+ providers = getattr(getattr(cfg, "brain", None), "providers", None)+ pc = providers.get(provider_id) if isinstance(providers, dict) else None+ model = (getattr(pc, "model", None) or "") if pc is not None else ""+ voice = (getattr(pc, "voice", None) or "") if pc is not None else ""+ return model, voice++[email protected]("/providers/{provider_id}/realtime-options")+async def get_realtime_options(provider_id: str, request: Request) -> RealtimeOptionsResponse:+ """Return the curated model+voice catalog for a realtime provider, plus+ the currently pinned selection.++ Realtime needs BOTH a model AND a voice per provider (unlike the+ single-selection ``/models`` endpoint), so this reads the two curated+ dicts directly rather than going through ``catalog_spec``.+ """+ _require_realtime_provider(provider_id)+ from jarvis.brain.model_catalog import REALTIME_MODELS, REALTIME_VOICES++ cfg = _resolve_cfg(request)+ current_model, current_voice = _current_realtime_selection(cfg, provider_id)+ return RealtimeOptionsResponse(+ provider=provider_id,+ models=[+ RealtimeOptionInfo(id=m.id, label=m.label)+ for m in REALTIME_MODELS.get(provider_id, [])+ ],+ voices=[+ RealtimeOptionInfo(id=v.id, label=v.label)+ for v in REALTIME_VOICES.get(provider_id, [])+ ],+ current_model=current_model,+ current_voice=current_voice,+ )++[email protected]("/providers/{provider_id}/realtime-options")+async def set_realtime_options(+ provider_id: str, body: RealtimeOptionsBody, request: Request+) -> RealtimeOptionsSaveResponse:+ """Pin the model and/or voice for a realtime provider.++ Persists to ``[brain.providers.<id>].model`` / ``.voice`` (+ drift-soll)+ and updates the in-memory config so the next realtime session picks it up+ with no process restart (``session.py::_open`` reads it fresh per+ session). Only the fields present in the body are written — an omitted+ field leaves its current value untouched.+ """+ spec = _require_realtime_provider(provider_id)+ if not _is_credential_present(spec):+ raise HTTPException(+ status_code=409,+ detail=f"Provider '{provider_id}' hat keine Credentials — erst API-Key setzen.",+ )+ model = body.model.strip() if body.model is not None else None+ voice = body.voice.strip() if body.voice is not None else None++ if model is not None or voice is not None:+ try:+ from jarvis.core.config_writer import set_brain_provider_model++ set_brain_provider_model(provider_id, model=model, voice=voice)+ except FileNotFoundError as exc:+ raise HTTPException(status_code=500, detail=str(exc)) from exc+ except Exception as exc: # noqa: BLE001+ raise HTTPException(+ status_code=500, detail=f"TOML-Write fehlgeschlagen: {exc}"+ ) from exc++ cfg = _resolve_cfg(request)+ if cfg is not None and getattr(cfg, "brain", None) is not None:+ try:+ providers = cfg.brain.providers+ pc = providers.get(provider_id)+ if pc is None:+ from jarvis.core.config import BrainProviderConfig++ pc = BrainProviderConfig()+ providers[provider_id] = pc+ if model is not None:+ pc.model = model+ if voice is not None:+ pc.voice = voice+ except Exception as exc: # noqa: BLE001 — frozen/detached cfg is not an error+ log.debug(+ "In-memory realtime-options update skipped for %s: %s", provider_id, exc+ )++ await _emit(+ request,+ SecretConfigured(key=f"brain.providers.{provider_id}", action="set"),+ )+ current_model, current_voice = _current_realtime_selection(cfg, provider_id)+ return RealtimeOptionsSaveResponse(+ ok=True,+ provider=provider_id,+ model=current_model,+ voice=current_voice,+ restart_required=False,+ )++@router.get("/codex/status")async def codex_status(request: Request) -> dict[str, Any]:return CodexAuthService(_codex_binary_path(request)).status().to_dict()diff --git a/tests/unit/brain/test_cu_model_selection.py b/tests/unit/brain/test_cu_model_selection.pyindex c95814a365..d03613c6b2 100644--- a/tests/unit/brain/test_cu_model_selection.py+++ b/tests/unit/brain/test_cu_model_selection.py@@ -25,6 +25,18 @@ def test_brain_provider_config_cu_model_defaults_none():assert BrainProviderConfig().cu_model is None+# --- config field: realtime voice (selectable Realtime model + voice) -------+++def test_brain_provider_config_has_voice_field():+ c = BrainProviderConfig(model="gpt-realtime", voice="echo")+ assert c.voice == "echo"+++def test_brain_provider_config_voice_defaults_empty():+ assert BrainProviderConfig().voice == ""++# --- BrainManager._cu_model precedence --------------------------------------diff --git a/tests/unit/realtime/test_gemini_live.py b/tests/unit/realtime/test_gemini_live.pyindex 1a7a79b31a..ee46fa7f5f 100644--- a/tests/unit/realtime/test_gemini_live.py+++ b/tests/unit/realtime/test_gemini_live.py@@ -132,6 +132,112 @@ async def test_close_calls_context_manager_aexit():assert aexit_calls == [(None, None, None)]+# ── open_session: selectable model + speech_config voice ─────────────────────+++class _FakeConnectCM:+ async def __aenter__(self):+ return SimpleNamespace(name="fake-live-session")++ async def __aexit__(self, *_a):+ return None+++class _FakeLiveAPI:+ def __init__(self) -> None:+ self.connect_calls: list[tuple[str, object]] = []++ def connect(self, *, model, config):+ self.connect_calls.append((model, config))+ return _FakeConnectCM()+++class _FakeAio:+ def __init__(self) -> None:+ self.live = _FakeLiveAPI()+++class _FakeGenaiClient:+ def __init__(self, *, api_key=None) -> None:+ self.api_key = api_key+ self.aio = _FakeAio()+++def _patch_genai_client(monkeypatch: pytest.MonkeyPatch) -> dict:+ """Patch ``google.genai.Client`` (the module attribute the adapter's lazy+ ``from google import genai`` resolves at call time) and stash the fake+ client instance created so the test can inspect what was passed to+ ``client.aio.live.connect(...)``."""+ holder: dict = {}++ def _make_client(*, api_key=None):+ client = _FakeGenaiClient(api_key=api_key)+ holder["client"] = client+ return client++ from google import genai++ monkeypatch.setattr(genai, "Client", _make_client)+ monkeypatch.setattr(+ "jarvis.plugins.realtime.gemini_live.get_provider_secret",+ lambda _name: "AIza-test",+ )+ return holder+++async def test_open_session_uses_cfg_model_when_set(monkeypatch: pytest.MonkeyPatch) -> None:+ holder = _patch_genai_client(monkeypatch)+ prov = GeminiLiveProvider()++ await prov.open_session(+ RealtimeSessionConfig(model="gemini-2.5-flash-native-audio-preview-12-2025")+ )++ model, _config = holder["client"].aio.live.connect_calls[0]+ assert model == "gemini-2.5-flash-native-audio-preview-12-2025"+++async def test_open_session_falls_back_to_hardcoded_default_model(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ holder = _patch_genai_client(monkeypatch)+ prov = GeminiLiveProvider()++ await prov.open_session(RealtimeSessionConfig(model=""))++ model, _config = holder["client"].aio.live.connect_calls[0]+ assert model == "gemini-3.1-flash-live-preview"+++async def test_open_session_builds_speech_config_when_voice_set(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ holder = _patch_genai_client(monkeypatch)+ prov = GeminiLiveProvider()++ await prov.open_session(RealtimeSessionConfig(voice="Puck"))++ _model, config = holder["client"].aio.live.connect_calls[0]+ assert config.speech_config is not None+ assert config.speech_config.voice_config.prebuilt_voice_config.voice_name == "Puck"+++async def test_open_session_omits_speech_config_when_voice_unset(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ holder = _patch_genai_client(monkeypatch)+ prov = GeminiLiveProvider()++ await prov.open_session(RealtimeSessionConfig(voice=""))++ _model, config = holder["client"].aio.live.connect_calls[0]+ assert config.speech_config is None++def test_module_does_not_import_google_genai_at_top_level():# AP-26: the SDK import is lazy inside methods, not at module import.src = pathlib.Path("jarvis/plugins/realtime/gemini_live.py").read_text("utf-8")diff --git a/tests/unit/realtime/test_openai_realtime.py b/tests/unit/realtime/test_openai_realtime.pynew file mode 100644index 0000000000..988b7af7b0--- /dev/null+++ b/tests/unit/realtime/test_openai_realtime.py@@ -0,0 +1,131 @@+"""Unit tests for the OpenAI GA realtime adapter's model/voice selection.++The ``openai`` SDK client is faked with plain objects (no network) so these+tests only assert what :func:`OpenAIRealtimeProvider.open_session` forwards+to ``client.realtime.connect(...)`` and ``conn.session.update(...)``.+"""++from __future__ import annotations++from typing import Any++import pytest++from jarvis.plugins.realtime.openai_realtime import OpenAIRealtimeProvider+from jarvis.realtime.protocol import RealtimeSessionConfig+++class _FakeConn:+ def __init__(self) -> None:+ self.session_updates: list[dict[str, Any]] = []++ @property+ def session(self) -> _FakeConn:+ return self++ async def update(self, session: dict[str, Any]) -> None:+ self.session_updates.append(session)+++class _FakeConnectCM:+ """What ``client.realtime.connect(model=...)`` returns — an async CM."""++ def __init__(self, conn: _FakeConn) -> None:+ self._conn = conn++ async def __aenter__(self) -> _FakeConn:+ return self._conn++ async def __aexit__(self, *_a: object) -> None:+ return None+++class _FakeRealtimeAPI:+ def __init__(self) -> None:+ self.connect_calls: list[str] = []+ self.last_conn = _FakeConn()++ def connect(self, *, model: str) -> _FakeConnectCM:+ self.connect_calls.append(model)+ return _FakeConnectCM(self.last_conn)+++class _FakeAsyncOpenAI:+ def __init__(self, *, api_key: str | None = None) -> None:+ self.api_key = api_key+ self.realtime = _FakeRealtimeAPI()+++def _patch_openai_client(monkeypatch: pytest.MonkeyPatch) -> _FakeAsyncOpenAI:+ """Patch ``openai.AsyncOpenAI`` (the module attribute the adapter's lazy+ ``from openai import AsyncOpenAI`` resolves at call time) and stash the+ single fake client instance created so the test can inspect it."""+ holder: dict[str, _FakeAsyncOpenAI] = {}++ def _make_client(*, api_key: str | None = None) -> _FakeAsyncOpenAI:+ client = _FakeAsyncOpenAI(api_key=api_key)+ holder["client"] = client+ return client++ import openai++ monkeypatch.setattr(openai, "AsyncOpenAI", _make_client)+ monkeypatch.setattr(+ "jarvis.plugins.realtime.openai_realtime.get_provider_secret",+ lambda _name: "sk-test",+ )+ return holder # type: ignore[return-value]+++async def test_open_session_uses_cfg_model_when_set(monkeypatch: pytest.MonkeyPatch) -> None:+ holder = _patch_openai_client(monkeypatch)+ prov = OpenAIRealtimeProvider()++ await prov.open_session(RealtimeSessionConfig(model="gpt-realtime-2.1"))++ client = holder["client"] # type: ignore[index]+ assert client.realtime.connect_calls == ["gpt-realtime-2.1"]+++async def test_open_session_falls_back_to_hardcoded_default_model(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ holder = _patch_openai_client(monkeypatch)+ prov = OpenAIRealtimeProvider()++ # Empty model ("" -- nothing pinned) must fall back to the adapter's own+ # hardcoded _MODEL constant, not an empty string over the wire.+ await prov.open_session(RealtimeSessionConfig(model=""))++ client = holder["client"] # type: ignore[index]+ assert client.realtime.connect_calls == ["gpt-realtime"]+++async def test_open_session_passes_voice_through_session_update(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ holder = _patch_openai_client(monkeypatch)+ prov = OpenAIRealtimeProvider()++ await prov.open_session(RealtimeSessionConfig(voice="echo"))++ client = holder["client"] # type: ignore[index]+ payload = client.realtime.last_conn.session_updates[0]+ assert payload["audio"]["output"]["voice"] == "echo"+++async def test_open_session_omits_voice_key_when_unset(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ holder = _patch_openai_client(monkeypatch)+ prov = OpenAIRealtimeProvider()++ await prov.open_session(RealtimeSessionConfig(voice=""))++ client = holder["client"] # type: ignore[index]+ payload = client.realtime.last_conn.session_updates[0]+ assert "voice" not in payload["audio"]["output"]diff --git a/tests/unit/realtime/test_protocol.py b/tests/unit/realtime/test_protocol.pyindex 62dfbf24a4..be299fe1cf 100644--- a/tests/unit/realtime/test_protocol.py+++ b/tests/unit/realtime/test_protocol.py@@ -20,3 +20,13 @@ def test_protocol_types_importable():# Protocols are runtime_checkable.assert hasattr(RealtimeProvider, "_is_runtime_protocol")assert hasattr(RealtimeSession, "_is_runtime_protocol")+++def test_session_config_has_selectable_model():+ from jarvis.realtime.protocol import RealtimeSessionConfig++ # Default "" -> the adapter's hardcoded fallback model (no regression).+ assert RealtimeSessionConfig().model == ""+ cfg = RealtimeSessionConfig(model="gpt-realtime-2.1", voice="echo")+ assert cfg.model == "gpt-realtime-2.1"+ assert cfg.voice == "echo"diff --git a/tests/unit/realtime/test_session.py b/tests/unit/realtime/test_session.pyindex 0f40c340df..3053e8e40c 100644--- a/tests/unit/realtime/test_session.py+++ b/tests/unit/realtime/test_session.py@@ -45,23 +45,74 @@ class FakeProvider:def __init__(self, events):self._events = events+ self.opened_with = Noneasync def can_open_duplex_session(self):return Trueasync def open_session(self, cfg):+ self.opened_with = cfgself.session = FakeSession(self._events)return self.session-def _cfg():+def _cfg(*, providers=None):from types import SimpleNamespacereturn SimpleNamespace(- brain=SimpleNamespace(reply_language="en"), voice=SimpleNamespace(mode="realtime")+ brain=SimpleNamespace(reply_language="en", providers=providers or {}),+ voice=SimpleNamespace(mode="realtime"),)+async def test_open_injects_active_providers_model_and_voice():+ """_open must resolve the model/voice from [brain.providers.<active+ provider's name>], not the dead cfg.voice.realtime_voice read."""+ from types import SimpleNamespace++ providers = {+ "fake": SimpleNamespace(model="gpt-realtime-2.1", voice="echo"),+ "other-provider": SimpleNamespace(model="should-not-be-used", voice="should-not-be-used"),+ }+ sess = RealtimeVoiceSession(+ session_id="s-model-voice",+ send_binary=lambda b: asyncio.sleep(0),+ send_json=lambda m: asyncio.sleep(0),+ provider=FakeProvider([]),+ config=_cfg(providers=providers),+ bus=None,+ )+ await sess.handle_control({"type": "audio_start", "sample_rate": 16000})+ await asyncio.sleep(0.02)+ await sess.end(reason="test")++ opened_cfg = sess._provider.opened_with+ assert opened_cfg.model == "gpt-realtime-2.1"+ assert opened_cfg.voice == "echo"+++async def test_open_defaults_to_empty_model_and_voice_when_unset():+ """No [brain.providers.<id>] entry -> "" / "" so the adapter falls back+ to its own hardcoded default (today's behavior, no regression)."""+ sess = RealtimeVoiceSession(+ session_id="s-default",+ send_binary=lambda b: asyncio.sleep(0),+ send_json=lambda m: asyncio.sleep(0),+ provider=FakeProvider([]),+ config=_cfg(),+ bus=None,+ )+ await sess.handle_control({"type": "audio_start", "sample_rate": 16000})+ await asyncio.sleep(0.02)+ await sess.end(reason="test")++ opened_cfg = sess._provider.opened_with+ assert opened_cfg.model == ""+ assert opened_cfg.voice == ""++@pytest.mark.asyncioasync def test_clean_turn_streams_audio_and_transcript():events = [diff --git a/tests/unit/test_config_writer_brain_provider_model_sync.py b/tests/unit/test_config_writer_brain_provider_model_sync.pyindex a3e32bd17b..56f991d1c8 100644--- a/tests/unit/test_config_writer_brain_provider_model_sync.py+++ b/tests/unit/test_config_writer_brain_provider_model_sync.py@@ -217,7 +217,7 @@ def test_writes_voice_to_toml_and_soll( # i18n-allowsample_toml: Path, sample_soll: Path, monkeypatch: pytest.MonkeyPatch # i18n-allow) -> None:"""The realtime voice picker persists like model/deep_model/cu_model —- same nested-table writer, same drift-soll sync (BUG-010 class).""" # i18n-allow: internal config-soll identifier ref+ same nested-table writer, same drift-soll sync.""" # i18n-allow: config-soll refmonkeypatch.setattr(config_writer, "_config_soll_path", lambda: sample_soll) # i18n-allowmonkeypatch.setattr(config_writer, "_set_user_env_var", lambda name, value: None)diff --git a/tests/unit/web/test_realtime_provider_category.py b/tests/unit/web/test_realtime_provider_category.pyindex 996329fe4d..bbe7373972 100644--- a/tests/unit/web/test_realtime_provider_category.py+++ b/tests/unit/web/test_realtime_provider_category.py@@ -214,3 +214,163 @@ def test_set_realtime_provider_preserves_sibling_worker_table(tmp_path: Path):assert 'provider = "claude-api"' in contentassert '[brain.realtime]' in contentassert 'provider = "openai-realtime"' in content+++# ---------------------------------------------------------------------------+# GET/PUT /api/providers/{id}/realtime-options+# (selectable Realtime model + voice, per realtime provider)+# ---------------------------------------------------------------------------+++def test_get_realtime_options_returns_curated_models_and_voices(monkeypatch):+ monkeypatch.setattr(cfg_mod, "get_secret", _only_openai_key)+ client = TestClient(_app())+ resp = client.get("/api/providers/openai-realtime/realtime-options")+ assert resp.status_code == 200+ body = resp.json()+ assert body["provider"] == "openai-realtime"+ voice_ids = {v["id"] for v in body["voices"]}+ assert voice_ids == {+ "alloy", "ash", "ballad", "coral", "echo", "sage", "shimmer", "verse",+ }+ model_ids = [m["id"] for m in body["models"]]+ assert model_ids[0] == "gpt-realtime" # the hardcoded default leads+ assert body["current_model"] == ""+ assert body["current_voice"] == ""+++def test_get_realtime_options_gemini_live_voices(monkeypatch):+ monkeypatch.setattr(cfg_mod, "get_secret", lambda *a, **kw: "AIza-test")+ client = TestClient(_app())+ resp = client.get("/api/providers/gemini-live/realtime-options")+ assert resp.status_code == 200+ body = resp.json()+ voice_ids = {v["id"] for v in body["voices"]}+ assert voice_ids == {+ "Puck", "Charon", "Kore", "Fenrir", "Aoede", "Orus", "Leda", "Zephyr",+ }+ assert body["models"][0]["id"] == "gemini-3.1-flash-live-preview"+++def test_get_realtime_options_reflects_pinned_selection(monkeypatch):+ monkeypatch.setattr(cfg_mod, "get_secret", _only_openai_key)+ app = _app()+ from jarvis.core.config import BrainProviderConfig++ app.state.config.brain.providers["openai-realtime"] = BrainProviderConfig(+ model="gpt-realtime-2.1", voice="echo"+ )+ client = TestClient(app)+ resp = client.get("/api/providers/openai-realtime/realtime-options")+ body = resp.json()+ assert body["current_model"] == "gpt-realtime-2.1"+ assert body["current_voice"] == "echo"+++def test_get_realtime_options_unknown_provider_404(monkeypatch):+ client = TestClient(_app())+ resp = client.get("/api/providers/does-not-exist/realtime-options")+ assert resp.status_code == 404+++def test_get_realtime_options_rejects_non_realtime_provider(monkeypatch):+ monkeypatch.setattr(cfg_mod, "get_secret", lambda *a, **kw: "sk-test")+ client = TestClient(_app())+ resp = client.get("/api/providers/gemini/realtime-options")+ assert resp.status_code == 400+++def test_put_realtime_options_persists_voice(monkeypatch):+ monkeypatch.setattr(cfg_mod, "get_secret", _only_openai_key)+ writes: list[tuple[str, str | None, str | None]] = []+ monkeypatch.setattr(+ config_writer,+ "set_brain_provider_model",+ lambda provider, *, model=None, voice=None, **_k: writes.append(+ (provider, model, voice)+ ),+ )+ app = _app()+ client = TestClient(app)+ resp = client.put(+ "/api/providers/openai-realtime/realtime-options", json={"voice": "echo"}+ )+ assert resp.status_code == 200+ body = resp.json()+ assert body["ok"] is True+ assert body["voice"] == "echo"+ assert body["restart_required"] is False+ assert ("openai-realtime", None, "echo") in writes+ assert app.state.config.brain.providers["openai-realtime"].voice == "echo"+++def test_put_realtime_options_persists_model_and_voice(monkeypatch):+ monkeypatch.setattr(cfg_mod, "get_secret", _only_openai_key)+ writes: list[tuple[str, str | None, str | None]] = []+ monkeypatch.setattr(+ config_writer,+ "set_brain_provider_model",+ lambda provider, *, model=None, voice=None, **_k: writes.append(+ (provider, model, voice)+ ),+ )+ app = _app()+ client = TestClient(app)+ resp = client.put(+ "/api/providers/openai-realtime/realtime-options",+ json={"model": "gpt-realtime-2.1", "voice": "echo"},+ )+ assert resp.status_code == 200+ body = resp.json()+ assert body["model"] == "gpt-realtime-2.1"+ assert body["voice"] == "echo"+ assert ("openai-realtime", "gpt-realtime-2.1", "echo") in writes+ pc = app.state.config.brain.providers["openai-realtime"]+ assert pc.model == "gpt-realtime-2.1"+ assert pc.voice == "echo"+++def test_put_realtime_options_omitted_field_leaves_it_unwritten(monkeypatch):+ """Only the field actually present in the body is persisted — mirrors the+ model/cu_model endpoints' partial-update contract."""+ monkeypatch.setattr(cfg_mod, "get_secret", _only_openai_key)+ writes: list[tuple[str, str | None, str | None]] = []+ monkeypatch.setattr(+ config_writer,+ "set_brain_provider_model",+ lambda provider, *, model=None, voice=None, **_k: writes.append(+ (provider, model, voice)+ ),+ )+ client = TestClient(_app())+ resp = client.put(+ "/api/providers/openai-realtime/realtime-options",+ json={"model": "gpt-realtime-2.1"},+ )+ assert resp.status_code == 200+ assert ("openai-realtime", "gpt-realtime-2.1", None) in writes+++def test_put_realtime_options_without_key_is_409(monkeypatch):+ monkeypatch.setattr(cfg_mod, "get_secret", lambda *a, **kw: None)+ client = TestClient(_app())+ resp = client.put(+ "/api/providers/openai-realtime/realtime-options", json={"voice": "echo"}+ )+ assert resp.status_code == 409+++def test_put_realtime_options_rejects_non_realtime_provider(monkeypatch):+ monkeypatch.setattr(cfg_mod, "get_secret", lambda *a, **kw: "sk-test")+ client = TestClient(_app())+ resp = client.put("/api/providers/gemini/realtime-options", json={"voice": "x"})+ assert resp.status_code == 400+++def test_put_realtime_options_unknown_provider_404(monkeypatch):+ monkeypatch.setattr(cfg_mod, "get_secret", lambda *a, **kw: "sk-test")+ client = TestClient(_app())+ resp = client.put(+ "/api/providers/does-not-exist/realtime-options", json={"voice": "x"}+ )+ assert resp.status_code == 404