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(config): realtime fallback-provider setter

rubenluetke10-beep6ebf0f27706e
diff --git a/jarvis/core/config_writer.py b/jarvis/core/config_writer.py
index 4562ed5dac..c8a7fcb8b9 100644
--- a/jarvis/core/config_writer.py
+++ b/jarvis/core/config_writer.py
@@ -1239,6 +1239,18 @@ def set_realtime_provider(provider: str, *, path: Path = DEFAULT_CONFIG_FILE) ->
_patch_realtime_provider_toml(path, provider)
+def set_realtime_fallback_provider(provider: str, *, path: Path = DEFAULT_CONFIG_FILE) -> None:
+ """Persist ``[brain.realtime] fallback_provider``.
+
+ The factory tries the fallback after the primary during the SAME handshake
+ (jarvis/realtime/factory.py reads ``provider`` then ``fallback_provider``),
+ so an explicit fallback is how a subscription primary degrades honestly
+ instead of silently losing realtime voice. Same TOML-only rationale as
+ :func:`set_realtime_provider`.
+ """
+ _patch_realtime_provider_toml(path, provider, key="fallback_provider")
+
+
def set_silence_window_ms(ms: int, *, path: Path = DEFAULT_CONFIG_FILE) -> None:
"""Persist the voice silence window to ``[speech] vad_silence_ms`` in jarvis.toml.
@@ -2299,8 +2311,8 @@ def _patch_worker_provider_toml(path: Path, name: str) -> None:
_atomic_write(path, out)
-def _patch_realtime_provider_toml(path: Path, name: str) -> None:
- """Set ``[brain.realtime] provider = name`` in the TOML.
+def _patch_realtime_provider_toml(path: Path, name: str, *, key: str = "provider") -> None:
+ """Set ``[brain.realtime] <key> = name`` in the TOML.
Unlike :func:`_patch_table`, this walks the NESTED ``brain`` -> ``realtime``
path instead of treating ``"brain.realtime"`` as a flat top-level key
@@ -2326,7 +2338,7 @@ def _patch_realtime_provider_toml(path: Path, name: str) -> None:
if realtime is None:
realtime = tomlkit.table()
brain["realtime"] = realtime
- realtime["provider"] = name
+ realtime[key] = name
out = tomlkit.dumps(doc)
if had_bom:
diff --git a/tests/unit/web/test_realtime_provider_category.py b/tests/unit/web/test_realtime_provider_category.py
index b6364f9975..3c6b17da7f 100644
--- a/tests/unit/web/test_realtime_provider_category.py
+++ b/tests/unit/web/test_realtime_provider_category.py
@@ -253,6 +253,18 @@ def test_set_realtime_provider_preserves_sibling_worker_table(tmp_path: Path):
assert 'provider = "openai-realtime"' in content
+def test_set_realtime_fallback_provider_keeps_primary(tmp_path: Path):
+ toml = tmp_path / "jarvis.toml"
+ toml.write_text(
+ '[brain.realtime]\nprovider = "codex-subscription-realtime"\n',
+ encoding="utf-8",
+ )
+ config_writer.set_realtime_fallback_provider("local-realtime", path=toml)
+ content = toml.read_text(encoding="utf-8")
+ assert 'provider = "codex-subscription-realtime"' in content
+ assert 'fallback_provider = "local-realtime"' in content
+
+
# ---------------------------------------------------------------------------
# GET/PUT /api/providers/{id}/realtime-options
# (selectable Realtime model + voice, per realtime provider)