mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-17 04:11:35 +00:00
A rejected OAuth token (HTTP 401 'User not found' from Nous Portal, Codex, xAI…) reached the desktop error card as 'Provider error' with Retry as the first action, which just replays the same dead credential. Backend: nonretryable_client_error_result dropped failure_reason / failure_retryable, so error_surface classified every non-retryable 4xx as a retryable provider failure. It now stamps the classifier verdict like the max-retries path, and auth-layer descriptors carry auth_kind (oauth|api_key, derived from the provider catalog tab) + provider_label. Desktop: an auth/oauth surface renders 'Authentication error', explains that the <provider> sign-in expired/was revoked, and offers 'Sign in to <provider> again' which launches that provider's existing onboarding OAuth flow scoped to the failed session's gateway profile. Retry stays as the follow-up click. Re-login to the provider already in use keeps the current model instead of swapping in the recommended default.
43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
"""A non-retryable 4xx (rejected OAuth token, bad key) must reach UI clients with the
|
|
classifier's verdict: without ``failure_reason`` the desktop error card read a 401 as a
|
|
retryable "Provider error" and offered Retry instead of a re-login."""
|
|
from __future__ import annotations
|
|
|
|
from agent.error_classifier import classify_api_error
|
|
from agent.error_surface import LAYER_AUTH, build_error_surface_from_result
|
|
from agent.turn_recovery import nonretryable_client_error_result
|
|
|
|
|
|
class _Rejected(Exception):
|
|
status_code = 401
|
|
|
|
def __init__(self) -> None:
|
|
super().__init__("HTTP 401: User not found.")
|
|
|
|
|
|
class _Agent:
|
|
log_prefix = ""
|
|
verbose = False
|
|
|
|
def _summarize_api_error(self, error):
|
|
return str(error)
|
|
|
|
def __getattr__(self, name): # status/persist/print helpers the terminal path calls
|
|
return lambda *args, **kwargs: None
|
|
|
|
|
|
def test_nonretryable_401_result_classifies_as_auth_for_the_ui():
|
|
error = _Rejected()
|
|
classified = classify_api_error(error, provider="nous", model="m")
|
|
result = nonretryable_client_error_result(
|
|
_Agent(), error, classified, status_code=401, api_kwargs=None, api_messages=[], messages=[],
|
|
conversation_history=None, api_call_count=1, approx_tokens=10, provider="nous",
|
|
base_url="https://inference-api.nousresearch.com/v1", model="m",
|
|
)
|
|
assert result["failure_reason"] == classified.reason.value
|
|
assert result["failure_retryable"] is classified.retryable is False
|
|
|
|
surface = build_error_surface_from_result(result, provider="nous", model="m")
|
|
assert surface["layer"] == LAYER_AUTH
|
|
assert surface["retryable"] is False
|
|
assert surface["auth_kind"] == "oauth"
|