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(brain): reserve the GPT-Live key for the voice call

rubenluetke10-beepeef36ad2d20b
diff --git a/jarvis/brain/factory.py b/jarvis/brain/factory.py
index da1f899b35..7798c5da62 100644
--- a/jarvis/brain/factory.py
+++ b/jarvis/brain/factory.py
@@ -1187,7 +1187,26 @@ def _phase2_full_brain(
startup_override: str | None = None
tier_cfg_startup = getattr(config.brain, "router", None)
tier_provider = tier_cfg_startup.provider if tier_cfg_startup else None
- if config.brain.primary and config.brain.primary != tier_provider:
+ # The realtime voice call owns its key (user mandate 2026-09-29: the GPT-Live
+ # key pays for the voice call and its thinking model only). While voice runs
+ # realtime the Brain tab is hidden, so a ``brain.primary`` left on that
+ # key's family is not a choice anyone can see — it must not pull text turns
+ # onto the voice budget when the router tier names another provider. A
+ # single-key install (no other router provider) keeps working on the key.
+ from jarvis.brain.voice_key import bills_voice_key
+
+ primary_on_voice_key = bills_voice_key(config, config.brain.primary)
+ if (
+ primary_on_voice_key
+ and tier_provider
+ and not bills_voice_key(config, tier_provider)
+ ):
+ log.info(
+ "Router stays on [brain.router].provider=%s: brain.primary=%s bills "
+ "the realtime voice key.",
+ tier_provider, config.brain.primary,
+ )
+ elif config.brain.primary and config.brain.primary != tier_provider:
startup_override = config.brain.primary
log.info(
"Startup override: brain.primary=%s overrides [brain.router].provider=%s",
@@ -2029,14 +2048,18 @@ def _build_flash_provider(jcfg: Any, ack_cfg: Any) -> Any:
if provider_name == "follow_brain":
brain_cfg = getattr(jcfg, "brain", None)
primary = getattr(brain_cfg, "primary", None) if brain_cfg else None
- if primary and primary in REGISTRY:
+ # A primary on the realtime voice key does not pull flash composition
+ # onto that key; the keyed fallback below picks another family first.
+ from jarvis.brain.voice_key import bills_voice_key
+
+ if primary and primary in REGISTRY and not bills_voice_key(jcfg, primary):
log.info(
"Flash-Brain: follow_brain -> %s (from brain.primary).",
primary,
)
provider_name = primary
else:
- fallback = _pick_keyed_flash_fallback(ack_cfg)
+ fallback = _pick_keyed_flash_fallback(ack_cfg, jcfg)
if fallback is None:
log.warning(
"Flash-Brain: brain.primary=%r has no Flash adapter "
@@ -2064,7 +2087,7 @@ def _build_flash_provider(jcfg: Any, ack_cfg: Any) -> Any:
return provider_cls(provider_cfg)
-def _pick_keyed_flash_fallback(ack_cfg: Any) -> str | None:
+def _pick_keyed_flash_fallback(ack_cfg: Any, jcfg: Any = None) -> str | None:
"""First REGISTRY provider family with a usable credential, or ``None``.
AP-21/AP-22: never hardcode a literal provider name as the fallback — a
@@ -2075,9 +2098,14 @@ def _pick_keyed_flash_fallback(ack_cfg: Any) -> str | None:
(local Ollama) needs no credential and is always considered usable.
"""
from jarvis.brain.ack_brain.providers import REGISTRY
+ from jarvis.brain.voice_key import bills_voice_key
from jarvis.core.config import get_provider_secret, get_secret
- for name in REGISTRY:
+ # Families on the realtime voice key are tried last (mandate 2026-09-29),
+ # so a single-key install still resolves while a multi-key one keeps the
+ # voice budget for the voice call.
+ names = sorted(REGISTRY, key=lambda name: bills_voice_key(jcfg, name))
+ for name in names:
provider_cfg = getattr(ack_cfg.providers, name, None)
if provider_cfg is None:
continue
diff --git a/jarvis/brain/resolver.py b/jarvis/brain/resolver.py
index 8c722e3a46..da535970e3 100644
--- a/jarvis/brain/resolver.py
+++ b/jarvis/brain/resolver.py
@@ -719,6 +719,16 @@ def _resolve_chain(config: JarvisConfig) -> list[tuple[str, str | None]]:
)
if has_reachable_alternative:
deduped = [entry for entry in deduped if entry[0] != "claude-api"]
+
+ # The realtime voice call owns its key (user mandate 2026-09-29). Families
+ # that bill it move to the end, so skill drafting, bios and other
+ # background resolves reach it only when nothing else can answer — a
+ # single-key install still works, a multi-key one stops draining the voice.
+ from jarvis.brain.voice_key import bills_voice_key
+
+ on_voice_key = [entry for entry in deduped if bills_voice_key(config, entry[0])]
+ if on_voice_key and len(on_voice_key) < len(deduped):
+ deduped = [entry for entry in deduped if entry not in on_voice_key] + on_voice_key
return deduped
diff --git a/jarvis/brain/voice_key.py b/jarvis/brain/voice_key.py
new file mode 100644
index 0000000000..c2f044f720
--- /dev/null
+++ b/jarvis/brain/voice_key.py
@@ -0,0 +1,59 @@
+"""Which paid key the realtime voice call owns, so other work can stay off it.
+
+A user who adds an API key to power a realtime voice model (GPT-Live) pays per
+token for every other request that happens to share that key. Text chat, agent
+reviews and health probes then drain the voice budget silently (live
+2026-09-29: the voice call failed with "no credits" after background work had
+spent the key). This module answers one question for those callers: does this
+brain provider bill the key that the configured voice call depends on?
+
+The answer comes from the plugins' own credential declarations — the realtime
+provider's ``credential_candidates`` against the brain provider's secret slots
+in ``PROVIDER_SECRET_CANDIDATES`` — never from a provider name (AP-21).
+"""
+
+from __future__ import annotations
+
+import logging
+from typing import Any
+
+log = logging.getLogger(__name__)
+
+_REALTIME_GROUP = "jarvis.realtime"
+
+
+def voice_key_slots(cfg: Any) -> frozenset[str]:
+ """Keyring slots the configured realtime voice provider bills, or empty.
+
+ Empty when the voice runs in pipeline mode, no realtime provider is set, or
+ the provider signs in without a key (a subscription voice owns no key).
+ Never raises: a plugin that cannot load owns nothing.
+ """
+ voice = getattr(cfg, "voice", None)
+ if str(getattr(voice, "mode", "") or "").strip() != "realtime":
+ return frozenset()
+ brain = getattr(cfg, "brain", None)
+ realtime = getattr(brain, "realtime", None)
+ provider_id = str(getattr(realtime, "provider", "") or "").strip()
+ if not provider_id:
+ return frozenset()
+ try:
+ from jarvis.core.registry import load
+
+ provider_cls = load(_REALTIME_GROUP, provider_id)
+ except Exception: # noqa: BLE001 - an unloadable plugin bills nothing
+ log.debug("voice_key_slots: realtime plugin %r not loadable", provider_id, exc_info=True)
+ return frozenset()
+ candidates = tuple(getattr(provider_cls, "credential_candidates", ()) or ())
+ return frozenset(str(slot) for slot, _env in candidates if slot)
+
+
+def bills_voice_key(cfg: Any, brain_provider: str | None) -> bool:
+ """Whether ``brain_provider`` pays with the key the voice call depends on."""
+ slots = voice_key_slots(cfg)
+ if not slots or not brain_provider:
+ return False
+ from jarvis.core.config import PROVIDER_SECRET_CANDIDATES
+
+ own = PROVIDER_SECRET_CANDIDATES.get(str(brain_provider).strip(), ())
+ return any(slot in slots for slot, _env in own)
diff --git a/jarvis/society/review.py b/jarvis/society/review.py
index 9beca02463..8aaa0480f9 100644
--- a/jarvis/society/review.py
+++ b/jarvis/society/review.py
@@ -74,6 +74,14 @@ async def _ask(runtime: Any, agent: Any, prompt: str) -> dict[str, Any] | None:
yield getter(provider_name, model or None, scope=f"society-review:{agent.agent_id}")
except Exception:
log.info("society: selected seat has no review provider", exc_info=True)
+ # A review is background work nobody waits on: a connected
+ # subscription answers before any per-token key (mandate
+ # 2026-09-29), and the keyed chain below stays the fallback.
+ from jarvis.brain.resolver import resolve_subscription_brain
+
+ subscription = resolve_subscription_brain(runtime.config())
+ if subscription is not None:
+ yield subscription
# Reuse the established authoring fallback chain, but allocate a
# separate scoped instance so native engines never share callers.
from .learning import default_creator_factory
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 186184083a..ff71286180 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -19,7 +19,7 @@
"billing": "Sprachdauer und Denkmodell werden getrennt abgerechnet. Cloud-Aufzeichnung ist aus.",
"save": "Speichern und GPT-Live nutzen",
"saved": "Gespeichert. Dein nächstes Gespräch nutzt diese Einstellungen.",
- "use_for_agents": "Diesen Key und dieses Modell für Agenten und Textchat nutzen",
+ "use_for_agents": "Agenten und Textchat zusätzlich über diesen Key abrechnen (pro Token)",
"agent_saved": "Agenten und Textchat nutzen jetzt dieses OpenAI-Modell.",
"setup_title": "Sprache & Denken",
"setup_description": "Wähle, wie Jarvis zuhört, antwortet und deine Werkzeuge nutzt.",
@@ -30,9 +30,9 @@
"connect": "Einrichten",
"local_provider": "Auf deiner Hardware",
"show_cloud": "Cloud-Anbieter anzeigen",
- "agents_separate": "Textchat und Hintergrundaufgaben nutzen deine Auswahl unter Agents. Die Sprache hat ihre eigenen Modelleinstellungen.",
+ "agents_separate": "Dein OpenAI-Key bezahlt nur das Sprachgespräch und sein Denkmodell. Chat, Gedächtnis und alle Hintergrundarbeit laufen über den Provider, den du unter Agents wählst.",
"shared_key_ready": "OpenAI verbunden · ein Key für Sprache und Denken",
- "shared_key_help": "Dieser OpenAI-Key versorgt GPT-Live und sein Denkmodell.",
+ "shared_key_help": "Dieser OpenAI-Key wird nur für GPT-Live und sein Denkmodell genutzt — sonst wird nichts darüber abgerechnet.",
"manage_key": "Key verwalten",
"conversation_heading": "Gespräch",
"conversation_help": "Kontinuierliches Zuhören und natürliche Sprache, auch bei Unterbrechungen.",
@@ -2017,7 +2017,7 @@
"cat_computer_use_desc": "Das Tool Model führt deine Aktionen aus: Es routet Sprachbefehle, plant Computer-Use auf deinem Bildschirm, startet Hintergrund-Agenten und steuert die App — unabhängig von deinem Chat-Brain.",
"cat_dictation_desc": "Das schnelle Modell, das diktierten Text aufräumt — Satzzeichen, Füllwörter und Satzgrenzen. Optional: Ohne Schlüssel hier kommt dein Diktat genau so an, wie es erkannt wurde.",
"cat_subagents_title": "{name}-Agents",
- "cat_subagents_desc": "Wähle, welcher Provider schwere Hintergrund-Aufgaben übernimmt.",
+ "cat_subagents_desc": "Dieser Provider übernimmt Textchat, Gedächtnis und Hintergrundaufgaben. Ein Abo kostet hier nichts extra; dein Voice-Key bleibt für das Sprachgespräch reserviert.",
"advanced_title": "Zugang & Integrationen",
"advanced_desc": "Optionale Extras: der Team-Key-Proxy, Telefonie und der Wissens-Wiki-Provider.",
"no_providers_in_tier": "In dieser Kategorie sind keine Provider verfügbar.",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 06af3bba94..b5348d5cf7 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -19,7 +19,7 @@
"billing": "Voice time and thinking usage are billed separately. Cloud recording is off.",
"save": "Save and use GPT-Live",
"saved": "Saved. Your next call will use these settings.",
- "use_for_agents": "Use this key and model for agents and text chat",
+ "use_for_agents": "Also bill agents and text chat to this key (per token)",
"agent_saved": "Agents and text chat now use this OpenAI model.",
"setup_title": "Voice & thinking",
"setup_description": "Choose how Jarvis listens, responds and uses your tools.",
@@ -30,9 +30,9 @@
"connect": "Set up",
"local_provider": "On your hardware",
"show_cloud": "Show cloud providers",
- "agents_separate": "Text chat and background tasks use your selection in Agents. Voice has its own model settings.",
+ "agents_separate": "Your OpenAI key pays only for the voice call and its thinking model. Chat, memory and all background work run on the provider you choose under Agents.",
"shared_key_ready": "OpenAI connected · one key for voice and thinking",
- "shared_key_help": "This OpenAI key serves both GPT-Live and its thinking model.",
+ "shared_key_help": "This OpenAI key is used only for GPT-Live and its thinking model — nothing else is billed to it.",
"manage_key": "Manage key",
"conversation_heading": "Conversation",
"conversation_help": "Continuous listening and natural speech, including interruptions.",
@@ -2050,7 +2050,7 @@
"cat_computer_use_desc": "The Tool Model runs your actions: it routes spoken commands, plans Computer-Use on your screen, starts background agents, and drives app controls — independent of your chat Brain.",
"cat_dictation_desc": "The fast model that tidies up dictated text — punctuation, filler words and sentence breaks. Optional: with no key here your dictation is delivered exactly as it was recognized.",
"cat_subagents_title": "{name}-Agents",
- "cat_subagents_desc": "Choose which provider runs heavy background tasks.",
+ "cat_subagents_desc": "This provider runs text chat, memory and background tasks. A subscription here costs nothing extra; your voice key stays reserved for the voice call.",
"advanced_title": "Access & Integrations",
"advanced_desc": "Optional extras: the team key proxy, telephony, and the knowledge Wiki provider.",
"no_providers_in_tier": "No providers available in this category.",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index f45e761582..861642056f 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -19,7 +19,7 @@
"billing": "El tiempo de voz y el razonamiento se facturan por separado. La grabación en la nube está desactivada.",
"save": "Guardar y usar GPT-Live",
"saved": "Guardado. La próxima conversación usará estos ajustes.",
- "use_for_agents": "Usar esta clave y modelo para agentes y chat de texto",
+ "use_for_agents": "Facturar también agentes y chat de texto a esta clave (por token)",
"agent_saved": "Los agentes y el chat ahora usan este modelo de OpenAI.",
"setup_title": "Voz y razonamiento",
"setup_description": "Elige cómo Jarvis escucha, responde y utiliza tus herramientas.",
@@ -30,9 +30,9 @@
"connect": "Configurar",
"local_provider": "En tu equipo",
"show_cloud": "Mostrar proveedores en la nube",
- "agents_separate": "El chat de texto y las tareas en segundo plano usan tu selección en Agents. La voz tiene sus propios modelos.",
+ "agents_separate": "Tu clave de OpenAI solo paga la llamada de voz y su modelo de razonamiento. El chat, la memoria y todo el trabajo en segundo plano usan el proveedor que elijas en Agents.",
"shared_key_ready": "OpenAI conectado · una clave para voz y razonamiento",
- "shared_key_help": "Esta clave de OpenAI sirve a GPT-Live y a su modelo de razonamiento.",
+ "shared_key_help": "Esta clave de OpenAI se usa solo para GPT-Live y su modelo de razonamiento; no se le factura nada más.",
"manage_key": "Gestionar clave",
"conversation_heading": "Conversación",
"conversation_help": "Escucha continua y habla natural, incluso con interrupciones.",
@@ -2017,7 +2017,7 @@
"cat_computer_use_desc": "El Tool Model ejecuta tus acciones: enruta comandos de voz, planifica Computer-Use en tu pantalla, inicia agentes en segundo plano y controla la app — independiente de tu Brain de chat.",
"cat_dictation_desc": "El modelo rápido que ordena el texto dictado: puntuación, muletillas y separación de frases. Opcional: sin clave aquí tu dictado llega tal y como se reconoció.",
"cat_subagents_title": "{name}-Agents",
- "cat_subagents_desc": "Elige qué proveedor ejecuta las tareas pesadas en segundo plano.",
+ "cat_subagents_desc": "Este proveedor ejecuta el chat de texto, la memoria y las tareas en segundo plano. Una suscripción aquí no cuesta nada extra; tu clave de voz queda reservada para la llamada.",
"advanced_title": "Acceso e integraciones",
"advanced_desc": "Extras opcionales: el proxy de claves de equipo, telefonía y el proveedor del Wiki de conocimiento.",
"no_providers_in_tier": "No hay proveedores disponibles en esta categoría.",
diff --git a/jarvis/ui/web/provider_routes.py b/jarvis/ui/web/provider_routes.py
index 18a0c83272..45353c6ca4 100644
--- a/jarvis/ui/web/provider_routes.py
+++ b/jarvis/ui/web/provider_routes.py
@@ -1410,10 +1410,14 @@ assert set(get_args(SectionHealthStatusLiteral)) == set(_section_health.SECTION_
"section-health status vocabulary drift (Pydantic Literal vs SSOT)"
)
-# Cache the rollup briefly so opening the API-Keys page / switching tabs does not
-# re-run the REAL connectivity tests on every render. ``?refresh=true`` (used by
-# the UI after a key save / provider switch) bypasses it.
-_SECTION_HEALTH_TTL_S = 45.0
+# Cache the rollup so opening the API-Keys page / switching tabs does not re-run
+# the REAL connectivity tests on every render. ``?refresh=true`` (used by the UI
+# after a key save / provider switch) bypasses it. The sidebar and dock mount
+# this poll in every window, and every frontend build reloads every window, so a
+# short TTL turned into a paid probe per provider about once a minute (live
+# 2026-09-29: the voice key ran dry on health checks). Selection changes still
+# re-check at once through the fingerprint and the explicit refresh.
+_SECTION_HEALTH_TTL_S = 30 * 60.0
_SECTION_HEALTH_KEYS = (
"brain",
"computer-use",
@@ -2031,10 +2035,16 @@ async def _compute_section_health(
)
binary_path = _codex_binary_path(request)
+ # The realtime section already probes the voice key. A brain on that same
+ # key would spend it a second time for the same answer, so it reports from
+ # configuration only.
+ from jarvis.brain.voice_key import bills_voice_key
+
checks = {
"brain": _tier_section_health(
cfg,
get_spec(subjects["brain"] or ""),
+ probe=not bills_voice_key(cfg, subjects["brain"]),
binary_path=binary_path,
),
# The Tool Model tier has its own model pin (tool_model → cu_model);
diff --git a/tests/unit/brain/test_voice_key.py b/tests/unit/brain/test_voice_key.py
new file mode 100644
index 0000000000..07b435319c
--- /dev/null
+++ b/tests/unit/brain/test_voice_key.py
@@ -0,0 +1,36 @@
+"""The realtime voice key is reserved for the voice call (mandate 2026-09-29)."""
+
+from __future__ import annotations
+
+from types import SimpleNamespace
+
+from jarvis.brain.voice_key import bills_voice_key, voice_key_slots
+
+
+def _cfg(mode: str, realtime_provider: str) -> SimpleNamespace:
+ return SimpleNamespace(
+ voice=SimpleNamespace(mode=mode),
+ brain=SimpleNamespace(realtime=SimpleNamespace(provider=realtime_provider)),
+ )
+
+
+def test_openai_live_reserves_the_openai_key() -> None:
+ cfg = _cfg("realtime", "openai-live")
+
+ assert "openai_api_key" in voice_key_slots(cfg)
+ assert bills_voice_key(cfg, "openai")
+ assert not bills_voice_key(cfg, "grok")
+ assert not bills_voice_key(cfg, "claude-cli")
+
+
+def test_pipeline_voice_reserves_nothing() -> None:
+ cfg = _cfg("pipeline", "openai-live")
+
+ assert voice_key_slots(cfg) == frozenset()
+ assert not bills_voice_key(cfg, "openai")
+
+
+def test_unknown_or_missing_realtime_provider_reserves_nothing() -> None:
+ assert voice_key_slots(_cfg("realtime", "")) == frozenset()
+ assert voice_key_slots(_cfg("realtime", "no-such-voice-plugin")) == frozenset()
+ assert not bills_voice_key(None, "openai")
diff --git a/tests/unit/society/test_review_responsiveness.py b/tests/unit/society/test_review_responsiveness.py
index 0d54a75fb0..60db530670 100644
--- a/tests/unit/society/test_review_responsiveness.py
+++ b/tests/unit/society/test_review_responsiveness.py
@@ -15,9 +15,11 @@ from jarvis.society.review import _ask
@pytest.mark.parametrize("fallback", [False, True])
async def test_review_provider_resolution_keeps_loop_responsive(monkeypatch, fallback):
from jarvis.agent_chat import runner_brain
+ from jarvis.brain import resolver
from jarvis.core import config
from jarvis.society import learning
+ monkeypatch.setattr(resolver, "resolve_subscription_brain", lambda cfg: None)
loop = asyncio.get_running_loop()
loop_thread = threading.get_ident()
entered = asyncio.Event()
@@ -73,12 +75,15 @@ async def test_review_provider_resolution_keeps_loop_responsive(monkeypatch, fal
@pytest.mark.asyncio
async def test_unavailable_review_providers_finish_without_stop_iteration(monkeypatch):
from jarvis.agent_chat import runner_brain
+ from jarvis.brain import resolver
from jarvis.core import config
from jarvis.society import learning
def unavailable(*args, **kwargs):
raise RuntimeError("no usable provider")
+ monkeypatch.setattr(resolver, "resolve_subscription_brain", lambda cfg: None)
+
monkeypatch.setattr(
runner_brain, "brain_manager", lambda: SimpleNamespace(_get_brain=unavailable)
)
@@ -87,3 +92,47 @@ async def test_unavailable_review_providers_finish_without_stop_iteration(monkey
runtime = SimpleNamespace(config=lambda: None, skills_for=lambda agent_id: None)
agent = SimpleNamespace(provider="primary", model="test", effort="low", agent_id="test")
assert await asyncio.wait_for(_ask(runtime, agent, "Evidence"), timeout=2) is None
+
+
+async def test_connected_subscription_reviews_before_the_keyed_chain(monkeypatch):
+ """Background review spends a subscription before any per-token key."""
+ from jarvis.agent_chat import runner_brain
+ from jarvis.brain import resolver
+ from jarvis.core import config
+ from jarvis.society import learning
+
+ answered = []
+
+ class Provider:
+ def __init__(self, name, *, fails=False):
+ self.name = name
+ self._model = ""
+ self._fails = fails
+
+ async def complete(self, request):
+ answered.append(self.name)
+ if self._fails:
+ raise RuntimeError(f"{self.name} unavailable")
+ yield BrainDelta(content='{"memories": [], "skill": null}')
+
+ class Creator:
+ def _candidate_brains(self):
+ yield Provider("paid-key"), "paid-key"
+
+ def getter(name, model, *, scope):
+ return Provider(name, fails=name == "seat")
+
+ monkeypatch.setattr(runner_brain, "brain_manager", lambda: SimpleNamespace(_get_brain=getter))
+ monkeypatch.setattr(config, "get_jarvis_agent_secret", lambda provider: None)
+ monkeypatch.setattr(learning, "default_creator_factory", lambda cfg: lambda *args: Creator())
+ subscription = Provider("subscription")
+ monkeypatch.setattr(resolver, "resolve_subscription_brain", lambda cfg: subscription)
+ runtime = SimpleNamespace(config=lambda: None, skills_for=lambda agent_id: None)
+ agent = SimpleNamespace(provider="seat", model="", effort="low", agent_id="test")
+
+ assert await asyncio.wait_for(_ask(runtime, agent, "Evidence"), timeout=2) == {
+ "memories": [],
+ "skill": None,
+ }
+ assert answered == ["seat", "subscription"]