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(agent-runtimes): answer gateway clients with fixed subscription errors
rubenluetke10-beepe452c25fbbd6
diff --git a/jarvis/agent_runtimes/gateway.py b/jarvis/agent_runtimes/gateway.pyindex c0f8d21356..a97aa015d5 100644--- a/jarvis/agent_runtimes/gateway.py+++ b/jarvis/agent_runtimes/gateway.py@@ -61,6 +61,15 @@ class GatewayError(Exception):self.code = code+def _subscription_message(exc: Exception) -> str:+ """Fixed wording for a failed subscription call; no exception text leaves."""+ from jarvis.live.subscription_auth import SubscriptionAuthError++ if isinstance(exc, SubscriptionAuthError) or getattr(exc, "code", "") == "login":+ return "The ChatGPT subscription needs a new sign-in in Jarvis."+ return "The ChatGPT subscription could not answer this turn."++@dataclass(frozen=True, slots=True)class Grant:"""Who a gateway token speaks for, and on which Jarvis provider."""@@ -216,7 +225,8 @@ async def stream_response(grant: Grant, args: dict[str, Any]) -> AsyncIterator[byield _sse(event)except (SubscriptionReasoningError, SubscriptionAuthError) as exc:log.info("runtime gateway: %s turn failed (%s)", grant.agent_id, type(exc).__name__)- yield _sse(_failed_event(str(exc), getattr(exc, "code", "subscription_unavailable")))+ code = getattr(exc, "code", "subscription_unavailable")+ yield _sse(_failed_event(_subscription_message(exc), code))async def complete_response(grant: Grant, args: dict[str, Any]) -> dict[str, Any]:@@ -237,7 +247,10 @@ async def complete_response(grant: Grant, args: dict[str, Any]) -> dict[str, Any# completed response with an empty ``output``.return {**finished, "output": finished.get("output") or items}except (SubscriptionReasoningError, SubscriptionAuthError) as exc:- raise GatewayError(str(exc), status=502, code="subscription_unavailable") from exc+ log.info("runtime gateway: %s call failed (%s)", grant.agent_id, type(exc).__name__)+ raise GatewayError(+ _subscription_message(exc), status=502, code="subscription_unavailable"+ ) from excraise GatewayError("ChatGPT ended without an answer.", status=502, code="incomplete")@@ -259,7 +272,10 @@ async def list_models(grant: Grant) -> list[dict[str, Any]]:try:rows = await _client(grant.account_id).list_models()except (SubscriptionReasoningError, SubscriptionAuthError) as exc:- raise GatewayError(str(exc), status=502, code="subscription_unavailable") from exc+ log.info("runtime gateway: %s call failed (%s)", grant.agent_id, type(exc).__name__)+ raise GatewayError(+ _subscription_message(exc), status=502, code="subscription_unavailable"+ ) from excreturn [{"id": row["id"], "object": "model", "owned_by": "openai"}for row in rowsdiff --git a/tests/unit/agent_runtimes/test_runtime_gateway.py b/tests/unit/agent_runtimes/test_runtime_gateway.pyindex 4fdb554aa6..a20848fbe8 100644--- a/tests/unit/agent_runtimes/test_runtime_gateway.py+++ b/tests/unit/agent_runtimes/test_runtime_gateway.py@@ -136,7 +136,10 @@ def test_a_failure_mid_stream_arrives_as_response_failed(fake, guarded) -> None:answer = _post(guarded, token, {"model": "gpt-5.6-sol", "input": "Hi", "stream": True})frames = [json.loads(line[5:]) for line in answer.text.splitlines() if line.startswith("data:")]assert frames[-1]["type"] == "response.failed"- assert "login expired" in frames[-1]["response"]["error"]["message"]+ message = frames[-1]["response"]["error"]["message"]+ # Fixed wording only: the client's exception text never leaves the gateway.+ assert "login expired" not in message+ assert message == "The ChatGPT subscription needs a new sign-in in Jarvis."def test_models_are_listed_in_the_openai_shape(fake, guarded) -> None: