test(fallback): classify authentication exception messages

This commit is contained in:
KDB
2026-09-03 18:31:35 +08:00
committed by Xubin Ren
parent 18d1a325b6
commit b321c63e1a
2 changed files with 16 additions and 2 deletions
+3 -2
View File
@@ -623,6 +623,8 @@ class FallbackProvider(LLMProvider):
raise
except Exception as exc:
error_name = type(exc).__name__.lower()
detail = str(exc).strip() or type(exc).__name__
detail_lower = detail.lower()
error_kind: str | None = None
error_should_retry: bool | None = None
if isinstance(exc, (httpx.TimeoutException, asyncio.TimeoutError)):
@@ -634,7 +636,7 @@ class FallbackProvider(LLMProvider):
elif any(
token in error_name
for token in ("auth", "credential", "permissiondenied", "unauthor")
):
) or any(token in detail_lower for token in _AUTHENTICATION_ERROR_TOKENS):
error_kind = "authentication"
elif "ratelimit" in error_name or "throttl" in error_name:
error_kind = "rate_limit"
@@ -652,7 +654,6 @@ class FallbackProvider(LLMProvider):
except (TypeError, ValueError):
error_status_code = None
detail = str(exc).strip() or type(exc).__name__
return LLMResponse(
content=f"Error calling LLM: {detail}",
finish_reason="error",