Skip to content

The agent that grows with you

fix(nous): classify the desktop's escaped-exception card with the request credential

kshitijk4poor564687b113fa
diff --git a/agent/error_classifier.py b/agent/error_classifier.py
index c075e618145..b6a324e5218 100644
--- a/agent/error_classifier.py
+++ b/agent/error_classifier.py
@@ -587,7 +587,7 @@ def _nous_welcome_tier(c: _Ctx) -> Optional[Verdict]:
# A named credential's fairshare 429 is an ordinary rate limit, whatever its body says. The
# one welcome refusal it does receive is the gateway's mirror 400 on the welcome host; its
# reconnect copy stands, only the sign-in card is withheld (``_welcome_surface_kind``).
- if status == 400 and welcome_route_refusal(status, c.msg) == "named_on_welcome_host":
+ if c.provider == "nous" and status == 400 and welcome_route_refusal(status, c.msg) == "named_on_welcome_host":
return _v(_R.format_error, retryable=False, should_fallback=True,
error_context={"welcome_route": "named_on_welcome_host"})
return None
@@ -603,7 +603,7 @@ def _nous_welcome_tier(c: _Ctx) -> Optional[Verdict]:
return _v(_R.rate_limit, should_fallback=True, error_context=ctx)
# The route-keyed dark-tier 403 applies only to a 403 that says nothing else: a safety refusal
# or a billing wall on the welcome host keeps its own classification (and its own recovery).
- plain_403 = c.provider == "nous" and not any(p in c.msg for p in _WELCOME_403_NAMED_PATTERNS)
+ plain_403 = not any(p in c.msg for p in _WELCOME_403_NAMED_PATTERNS)
kind = welcome_route_refusal(status, c.msg, c.base_url if plain_403 else None)
if kind is None:
return None
diff --git a/agent/error_surface.py b/agent/error_surface.py
index 21453bd7566..d03512c26e8 100644
--- a/agent/error_surface.py
+++ b/agent/error_surface.py
@@ -179,7 +179,9 @@ def build_error_surface_from_result(result: Any, provider: str = "", model: str
return None
-def build_error_surface_from_exception(exc: BaseException, provider: str = "", model: str = "") -> Optional[dict]:
+def build_error_surface_from_exception(
+ exc: BaseException, provider: str = "", model: str = "", api_key: Any = None,
+) -> Optional[dict]:
"""Descriptor for an exception that escaped the turn dispatcher.
API/transport exceptions go through ``classify_api_error`` (same taxonomy
@@ -195,7 +197,7 @@ def build_error_surface_from_exception(exc: BaseException, provider: str = "", m
from agent.error_classifier import classify_api_error
- classified = classify_api_error(exc, provider=provider, model=model)
+ classified = classify_api_error(exc, provider=provider, model=model, api_key=api_key)
synthetic = {"error": classified.message or message, "failure_reason": classified.reason.value}
surface = build_error_surface_from_result(synthetic, provider=provider, model=model)
if surface is not None:
diff --git a/tui_gateway/session_auto_continue.py b/tui_gateway/session_auto_continue.py
index a3f8c1c134d..9a82ca0568d 100644
--- a/tui_gateway/session_auto_continue.py
+++ b/tui_gateway/session_auto_continue.py
@@ -379,7 +379,8 @@ def _emit_terminal_turn_error(
with contextlib.suppress(Exception):
from agent.error_surface import build_error_surface_from_exception
error_surface = build_error_surface_from_exception(
- error, provider=str(getattr(agent, "provider", "") or ""), model=str(getattr(agent, "model", "") or ""))
+ error, provider=str(getattr(agent, "provider", "") or ""), model=str(getattr(agent, "model", "") or ""),
+ api_key=getattr(agent, "api_key", None))
with session["history_lock"]:
_fail_inflight_turn(session, error, error_surface=error_surface)
turn = session.get("inflight_turn") or {}