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(providers): name the cause when a Live status probe is refused

rubenluetke10-beep7b58134d4762
diff --git a/jarvis/brain/provider_test.py b/jarvis/brain/provider_test.py
index deb70569cd..e6933ff39c 100644
--- a/jarvis/brain/provider_test.py
+++ b/jarvis/brain/provider_test.py
@@ -18,6 +18,7 @@ mirror it (anti-drift, BUG-008 class).
from __future__ import annotations
import asyncio
+import json
import re
from collections.abc import Awaitable, Callable
from dataclasses import dataclass
@@ -347,6 +348,31 @@ def _resolve_provider_option(cfg: Any, provider: str, field: str) -> str:
return ""
+def _continuous_rejection(event: dict) -> str:
+ """Explain a rejected continuous-voice session without its provider body.
+
+ The provider's error text is classified here and then dropped (AP-34); only
+ our own sentence for that class leaves. Live 2026-09-29: an OpenAI key with
+ no credits was reported as "rejected the selected session, check the
+ model settings", which sent the user to the wrong screen.
+ """
+ try:
+ raw = json.dumps(event.get("error") or event, default=str)
+ except (TypeError, ValueError):
+ raw = ""
+ status = classify_provider_error(raw)
+ if status == NO_CREDITS:
+ return "Continuous voice refused the session: the account has no credits left."
+ if status == RATE_LIMITED:
+ return "Continuous voice refused the session: too many requests right now."
+ if status == BAD_KEY:
+ return "Continuous voice refused the session: HTTP 401, the key was rejected."
+ return (
+ "Continuous voice rejected the selected session. "
+ "Check the Live model, voice and thinking-model settings."
+ )
+
+
async def _default_realtime_probe(spec: Any, cfg: Any, *, timeout_s: float) -> float:
"""Open and close the exact selected realtime provider.
@@ -411,10 +437,7 @@ async def _default_realtime_probe(spec: Any, cfg: Any, *, timeout_s: float) -> f
await session.send({"type": "session.close"})
return latency_ms
if event.get("type") in {"error", "session.closed"}:
- raise RuntimeError(
- "Continuous voice rejected the selected session. "
- "Check the Live model, voice and thinking-model settings."
- )
+ raise RuntimeError(_continuous_rejection(event))
finally:
await session.close()
diff --git a/tests/unit/brain/test_provider_test_live.py b/tests/unit/brain/test_provider_test_live.py
index 005c168860..749249a938 100644
--- a/tests/unit/brain/test_provider_test_live.py
+++ b/tests/unit/brain/test_provider_test_live.py
@@ -135,3 +135,34 @@ async def test_existing_realtime_adapters_keep_their_contract(probe):
assert isinstance(probe.opened[0], RealtimeSessionConfig)
assert probe.connection.closed
assert not probe.receiving.is_set()
+
+
+ ("error", "status", "words"),
+ [
+ ({"code": "insufficient_quota", "message": "private provider body"}, "no_credits",
+ "no credits"),
+ ({"code": "rate_limit_exceeded", "message": "private provider body"}, "rate_limited",
+ "too many requests"),
+ ({"code": "invalid_api_key", "message": "private provider body"}, "error",
+ "selected session"),
+ ],
+)
+async def test_rejected_live_probe_names_the_cause_without_the_body(
+ probe, error, status, words
+):
+ """Live 2026-09-29: an empty balance read as "check the model settings"."""
+ from jarvis.brain.provider_test import classify_provider_error
+
+ async def receive():
+ return {"type": "error", "error": error}
+
+ probe.connection.receive = receive
+ with pytest.raises(RuntimeError) as caught:
+ await _default_realtime_probe(probe.spec, probe.cfg, timeout_s=1)
+ message = str(caught.value)
+ assert words in message
+ assert "private provider body" not in message
+ assert classify_provider_error(message) == status
+ assert probe.connection.closed