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
fix(voice): say when an account is not offered subscription voice (#627)
Ruben Lütkebadf2ff80863
diff --git a/jarvis/live/session.py b/jarvis/live/session.pyindex c3320cd454..fe9edad15f 100644--- a/jarvis/live/session.py+++ b/jarvis/live/session.py@@ -1130,6 +1130,9 @@ class LiveVoiceSession:cause = {NO_CREDITS: "no_credits", RATE_LIMITED: "rate_limited"}.get(status, "unavailable")+ if getattr(exc, "code", "") == "voice_not_offered":+ # Waiting does not help here: the account has to change.+ cause = "not_offered"log.warning("Live session could not start (cause=%s): %s", cause, exc)try:await self._send_json(diff --git a/jarvis/live/subscription.py b/jarvis/live/subscription.pyindex 76b961b2fa..285b487672 100644--- a/jarvis/live/subscription.py+++ b/jarvis/live/subscription.py@@ -387,6 +387,7 @@ class SubscriptionLiveVoiceSession(LiveVoiceSession):safe = {"authentication_required","access_denied",+ "voice_not_offered","quota_exhausted","rate_limited","invalid_configuration",@@ -961,7 +962,7 @@ class SubscriptionLiveVoiceSession(LiveVoiceSession):if code not in {"authentication_required", "access_denied", "quota_exhausted", "rate_limited","invalid_configuration", "subscription_auth_unavailable",- "subscription_account_changed",+ "subscription_account_changed", "voice_not_offered",}:return Falseawait self._failure(code, terminal=True)diff --git a/jarvis/live/subscription_auth.py b/jarvis/live/subscription_auth.pyindex 5369f1aa39..e9229c140b 100644--- a/jarvis/live/subscription_auth.py+++ b/jarvis/live/subscription_auth.py@@ -43,6 +43,9 @@ class SubscriptionAuthError(RuntimeError):class SubscriptionCredentials:access_token: str = field(repr=False)account_id: str = field(repr=False)+ # The plan the login names for itself. It explains a refusal the server+ # already made; it never decides whether a request is sent.+ plan: str = field(default="", repr=False)def _claims(token: object) -> dict[str, Any]:@@ -71,13 +74,18 @@ def _credentials(data: dict[str, Any]) -> SubscriptionCredentials:if access.startswith("sk-") or any(c in access for c in "\r\n"):raise SubscriptionAuthError("The selected account does not contain a ChatGPT OAuth login.")account = _string(tokens.get("account_id")) or _string(data.get("account_id"))+ plan = ""for token in (tokens.get("id_token"), access):auth_claim = _claims(token).get("https://api.openai.com/auth")- if not account and isinstance(auth_claim, dict):+ if not isinstance(auth_claim, dict):+ continue+ if not account:account = _string(auth_claim.get("chatgpt_account_id"))+ if not plan:+ plan = _string(auth_claim.get("chatgpt_plan_type"))if not account or any(c in account for c in "\r\n"):raise SubscriptionAuthError("This ChatGPT login has no account identity. Sign in again.")- return SubscriptionCredentials(access_token=access, account_id=account)+ return SubscriptionCredentials(access_token=access, account_id=account, plan=plan)def _needs_refresh(data: dict[str, Any]) -> bool:diff --git a/jarvis/live/subscription_reasoning.py b/jarvis/live/subscription_reasoning.pyindex 6a368f4644..b4b00eb129 100644--- a/jarvis/live/subscription_reasoning.py+++ b/jarvis/live/subscription_reasoning.py@@ -16,7 +16,7 @@ from uuid import uuid4from jarvis.core.http_pool import HttpClientPoolfrom jarvis.core.protocols import BrainDelta, BrainRequest-from jarvis.live.subscription_auth import SubscriptionCredentials+from jarvis.live.subscription_auth import SubscriptionAuthError, SubscriptionCredentials_BASE_URL = "https://chatgpt.com/backend-api/codex"_MAX_EVENT_CHARS = 2 * 1024 * 1024@@ -148,6 +148,7 @@ class SubscriptionReasoning:self._pool = http_pool or HttpClientPool(timeout_s=60.0)self._session_id = session_id or str(uuid4())self._model_efforts: dict[str, tuple[str, ...]] = {}+ self._catalog_slugs: frozenset[str] = frozenset()def _headers(self, credentials: SubscriptionCredentials) -> dict[str, str]:return {@@ -189,6 +190,13 @@ class SubscriptionReasoning:raise SubscriptionReasoningError("The ChatGPT model catalog is unavailable.")models: list[dict[str, Any]] = []model_efforts: dict[str, tuple[str, ...]] = {}+ # Hidden rows count too: a model the picker does not list may+ # still be one this account can use.+ self._catalog_slugs = frozenset(+ row["slug"]+ for row in rows+ if isinstance(row, dict) and isinstance(row.get("slug"), str)+ )for row in rows:if not isinstance(row, dict) or row.get("visibility", "list") != "list":continue@@ -293,7 +301,19 @@ class SubscriptionReasoning:if response.status_code == 401 and attempt == 0:continueif response.status_code != 200:- raise await _http_failure(response)+ failure = await _http_failure(response)+ if (+ failure.status in (400, 404)+ and failure.code == "invalid_request_error"+ and await self._unlisted(model)+ ):+ # The backend refuses a model the account no longer+ # has with a bare 400. Live 2026-10-13: a model+ # saved under a plan that had since ended.+ failure = _failure(+ failure.status, {"error": {"code": "model_not_found"}}+ )+ raise failureasync for event in self._events(response):yield eventreturn@@ -302,6 +322,20 @@ class SubscriptionReasoning:raise _failure() from excraise _failure(401)+ async def _unlisted(self, model: str) -> bool:+ """True when the account's own catalog answers and does not carry ``model``.++ One catalog request, no inference, and only after a request was+ already refused.+ """+ try:+ await self.list_models()+ except (SubscriptionReasoningError, SubscriptionAuthError): # the given refusal stands+ # No catalog, or the login went away meanwhile: the refusal the+ # backend already gave is the one reported.+ return False+ return bool(self._catalog_slugs) and model not in self._catalog_slugs+async def snap_effort(self, model: str, requested: str) -> str:"""The level ``model`` offers closest to ``requested`` ("" = its default).diff --git a/jarvis/plugins/realtime/openai_subscription_live.py b/jarvis/plugins/realtime/openai_subscription_live.pyindex a1802db578..2643d15c0e 100644--- a/jarvis/plugins/realtime/openai_subscription_live.py+++ b/jarvis/plugins/realtime/openai_subscription_live.py@@ -43,6 +43,7 @@ SUBSCRIPTION_VOICES = (_MAX_SDP_BYTES = 256 * 1024_MAX_FRAME_BYTES = 1024 * 1024_MAX_SEEN_EVENTS = 8192+_PLAN = re.compile(r"[a-z0-9][a-z0-9_ -]{0,31}\Z")_CALL_ID = re.compile(r"(?:rtc_[A-Za-z0-9_-]+|[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12})\Z")@@ -51,12 +52,20 @@ _CALL_ID = re.compile(class SubscriptionLiveError(RuntimeError):"""Static, safe error classification for UI recovery and no-key fallback."""- def __init__(self, code: str, *, allocation_unconfirmed: bool = False) -> None:+ def __init__(+ self, code: str, *, allocation_unconfirmed: bool = False, plan: str = ""+ ) -> None:self.code = codeself.allocation_unconfirmed = allocation_unconfirmed+ plan = plan.strip().lower()+ named = f" ({plan.replace('_', ' ').title()} plan)" if _PLAN.fullmatch(plan) else ""messages = {"authentication_required": "Reconnect your ChatGPT subscription before starting voice.","access_denied": "The ChatGPT account does not allow this GPT-Live session.",+ "voice_not_offered": (+ f"The selected ChatGPT account{named} is not offered subscription voice. "+ "Check its plan or select another account in Agent accounts."+ ),"quota_exhausted": "The ChatGPT subscription voice allowance is exhausted.","rate_limited": "ChatGPT subscription voice is temporarily rate limited.","invalid_configuration": "The selected subscription voice configuration was rejected.",@@ -482,6 +491,7 @@ class OpenAISubscriptionLiveProvider:self._connection_permit = connection_permitself._http_client_factory = http_client_factoryself._websocket_connect = websocket_connect+ self._plan = ""async def can_open_duplex_session(self) -> bool:return callable(self._credentials)@@ -503,6 +513,7 @@ class OpenAISubscriptionLiveProvider:account = getattr(credential, "account_id", "")if not token or not account:raise SubscriptionLiveError("authentication_required")+ self._plan = str(getattr(credential, "plan", "") or "")return {"Authorization": f"Bearer {token}", "chatgpt-account-id": account}async def _retire_allocation(self, call_id: str, headers: dict, connector: Any) -> bool:@@ -664,6 +675,12 @@ class OpenAISubscriptionLiveProvider:# never switch the billing source.headers = {**await self._headers(force_refresh=True), **request_headers}continue+ if response.status_code == 404:+ # The call route does not exist for this account: no+ # retry reaches it, and "temporarily unavailable"+ # sends the user waiting for nothing. Live+ # 2026-10-13: an account whose paid plan had ended.+ raise SubscriptionLiveError("voice_not_offered", plan=self._plan)if response.status_code >= 300:raise SubscriptionLiveError(_error_code(response.status_code))allocated = Truediff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.pyindex d5e79e2e84..61af1806c6 100644--- a/jarvis/realtime/session.py+++ b/jarvis/realtime/session.py@@ -1790,6 +1790,24 @@ _HANDSHAKE_FAILURE_MESSAGES: dict[str, dict[str, str]] = {"Carrega-o no fornecedor e volta a funcionar."),},+ "not_offered": {+ "de": ( # i18n-allow: localized runtime voice output+ "Dein Konto bietet diese Sprachverbindung gerade nicht an. " # i18n-allow+ "Prüfe den Tarif oder wähle ein anderes Konto." # i18n-allow+ ),+ "en": (+ "Your account does not offer this voice connection right now. "+ "Check its plan or select another account."+ ),+ "es": ( # i18n-allow: localized runtime voice output+ "Tu cuenta no ofrece esta conexión de voz ahora mismo. "+ "Revisa el plan o elige otra cuenta."+ ),+ "pt": ( # i18n-allow: localized runtime voice output+ "A tua conta não oferece esta ligação de voz neste momento. "+ "Verifica o plano ou escolhe outra conta."+ ),+ },"dropped": {"de": ( # i18n-allow: localized runtime voice output"Die Sprachverbindung ist abgebrochen." # i18n-allowdiff --git a/tests/contract/test_live_surface_lifecycle.py b/tests/contract/test_live_surface_lifecycle.pyindex c19fa6591b..83d12e9d66 100644--- a/tests/contract/test_live_surface_lifecycle.py+++ b/tests/contract/test_live_surface_lifecycle.py@@ -159,3 +159,30 @@ async def test_an_empty_balance_is_spoken_instead_of_a_silent_hangup():spoken = [f for f in frames if f.get("type") == "error_spoken"]assert len(spoken) == 1assert "credit" in spoken[0]["text"].lower()++[email protected]("language,word", [("en", "plan"), ("de", "Tarif")]) # i18n-allow+async def test_an_account_without_voice_is_told_to_change_the_account(language, word):+ """Live 2026-10-13: "temporarily unavailable" kept a user waiting for days+ on an account whose plan no longer carried subscription voice."""+ from jarvis.plugins.realtime.openai_subscription_live import SubscriptionLiveError++ frames = []++ async def send(frame):+ frames.append(frame)++ session = LiveVoiceSession(+ session_id="live-not-offered",+ bus=None,+ send_json=send,+ send_binary=send,+ config=SimpleNamespace(brain=SimpleNamespace(reply_language=language)),+ providers=[SimpleNamespace(name="test")],+ )+ await session._announce_start_failure(SubscriptionLiveError("voice_not_offered", plan="free"))++ spoken = [f for f in frames if f.get("type") == "error_spoken"]+ assert len(spoken) == 1+ assert word in spoken[0]["text"]diff --git a/tests/unit/agent_runtimes/test_subscription_rejections.py b/tests/unit/agent_runtimes/test_subscription_rejections.pyindex 10792cc2cd..1510a1a0dd 100644--- a/tests/unit/agent_runtimes/test_subscription_rejections.py+++ b/tests/unit/agent_runtimes/test_subscription_rejections.py@@ -63,7 +63,11 @@ def test_rejection_preserves_status_and_safe_reason(assert hint in error["message"]assert "private-provider-body" not in response.textassert "private-code-must-not-leak" not in response.text- assert len(requests) == 1+ # The refused request is never replayed. An unexplained 400 may ask the+ # account's model catalog once, which runs no inference.+ paths = [request.url.path for request in requests]+ assert paths.count("/backend-api/codex/responses") == 1+ assert len(paths) - 1 == (1 if (status, code) == (400, "private-code-must-not-leak") else 0)@pytest.mark.parametrize("body", [b"not JSON", b"x" * 70_000], ids=["invalid", "oversized"])diff --git a/tests/unit/live/test_subscription_auth.py b/tests/unit/live/test_subscription_auth.pyindex 6e0c6c634e..e7713fd9b3 100644--- a/tests/unit/live/test_subscription_auth.py+++ b/tests/unit/live/test_subscription_auth.py@@ -313,3 +313,27 @@ async def test_close_budget_leaves_refresh_pool_open_until_persistence(tmp_path,release.set()await auth.aclose()await asyncio.wait_for(finished.wait(), timeout=2)+++async def test_the_login_plan_is_read_as_metadata_and_never_required(tmp_path):+ data = _write(tmp_path)+ auth = SubscriptionAuth(account=_account(tmp_path))+ assert (await auth.credentials()).plan == ""+ await auth.aclose()++ payload = {+ "exp": time.time() + 3600,+ "https://api.openai.com/auth": {+ "chatgpt_account_id": "test-account",+ "chatgpt_plan_type": "free",+ },+ }+ encoded = base64.urlsafe_b64encode(json.dumps(payload).encode()).decode().rstrip("=")+ data["tokens"]["id_token"] = f"fixture.{encoded}.signature"+ (tmp_path / "auth.json").write_text(json.dumps(data), encoding="utf-8")+ auth = SubscriptionAuth(account=_account(tmp_path))+ credentials = await auth.credentials()+ assert credentials.plan == "free"+ assert "free" not in repr(credentials)+ await auth.aclose()diff --git a/tests/unit/live/test_subscription_reasoning.py b/tests/unit/live/test_subscription_reasoning.pyindex bb7662dd5d..d57bd04f85 100644--- a/tests/unit/live/test_subscription_reasoning.py+++ b/tests/unit/live/test_subscription_reasoning.py@@ -400,3 +400,64 @@ async def test_brain_accepts_protocol_req_keyword():deltas = [delta async for delta in brain.complete(req=BrainRequest(messages=()))]assert deltas[-1].finish_reason == "stop"await reasoning.aclose()+++ "catalog,code",+ [+ ([{"slug": "other-model", "visibility": "list"}], "model_not_found"),+ ([{"slug": "chosen-model", "visibility": "hide"}], "invalid_request_error"),+ ([], "invalid_request_error"),+ (None, "invalid_request_error"),+ ],+)+async def test_a_refused_model_the_account_no_longer_carries_is_named(catalog, code):+ """Live 2026-10-13: a model saved under a plan that had ended was refused+ with a bare 400, reported only as "ChatGPT rejected this request"."""+ requests = []++ def handler(request):+ requests.append(request.url.path)+ if request.url.path.endswith("/models"):+ if catalog is None:+ return httpx.Response(500, text="sensitive-body")+ return httpx.Response(200, json={"models": catalog})+ return httpx.Response(400, text="sensitive-body")++ reasoning, _ = _reasoning(handler)+ with pytest.raises(SubscriptionReasoningError) as caught:+ await _collect(reasoning)+ assert caught.value.code == code and caught.value.status == 400+ assert ("unavailable on this ChatGPT subscription" in str(caught.value)) is (+ code == "model_not_found"+ )+ assert "sensitive-body" not in str(caught.value)+ # One inference request, never replayed; at most one free catalog request.+ assert requests.count("/backend-api/codex/responses") == 1+ assert requests.count("/backend-api/codex/models") == 1+ await reasoning.aclose()+++async def test_a_login_lost_during_the_catalog_check_keeps_the_original_refusal():+ from jarvis.live.subscription_auth import SubscriptionAuthError++ calls = []++ async def credentials(*, force_refresh=False):+ calls.append(force_refresh)+ if len(calls) > 1:+ raise SubscriptionAuthError("Sign in to the selected ChatGPT account again.")+ return SubscriptionCredentials("fixture-access", "fixture-account")++ pool = HttpClientPool(+ timeout_s=1,+ transport=httpx.MockTransport(lambda _request: httpx.Response(400, text="sensitive-body")),+ )+ reasoning = SubscriptionReasoning(credentials, http_pool=pool)+ with pytest.raises(SubscriptionReasoningError) as caught:+ await _collect(reasoning)+ assert caught.value.code == "invalid_request_error" and caught.value.status == 400+ assert len(calls) == 2+ await reasoning.aclose()diff --git a/tests/unit/live/test_subscription_wire.py b/tests/unit/live/test_subscription_wire.pyindex cb76a350f8..cd7f3aa14f 100644--- a/tests/unit/live/test_subscription_wire.py+++ b/tests/unit/live/test_subscription_wire.py@@ -440,3 +440,30 @@ async def test_cancelled_setup_retires_allocated_call_without_new_mutation():assert len(wire.requests) == 1assert wire.socket.sent == [{"type": "session.close"}]assert wire.socket.closed == 1+++ "plan,named",+ [("free", "(Free plan)"), ("", "account is not"), ("evil\nplan: <b>", "account is not")],+)+async def test_a_refused_call_route_names_the_account_instead_of_a_passing_outage(plan, named):+ """Live 2026-10-13: an account whose paid plan had ended got 404 on every+ call and was told voice is "temporarily unavailable" for days."""+ wire = FakeSubscriptionLiveWire([httpx.Response(404, text="provider-private-secret")])++ plain = wire.credentials++ async def credentials(*, force_refresh: bool = False):+ login = await plain(force_refresh=force_refresh)+ login.plan = plan+ return login++ wire.credentials = credentials+ with pytest.raises(SubscriptionLiveError) as caught:+ await wire.provider().open_session(wire.config())+ assert caught.value.code == "voice_not_offered"+ assert named in str(caught.value)+ assert "temporarily" not in str(caught.value)+ assert "provider-private-secret" not in str(caught.value)+ assert "evil" not in str(caught.value)+ assert not wire.connects and len(wire.requests) == 1