fix: rotate credential pool on 403 (Forbidden) responses

Previously _handle_credential_pool_error handled 401, 402, and 429
but silently ignored 403. When a provider returns 403 for a revoked or
unauthorised credential (e.g. Nous agent_key invalidated by a newer
login), the pool was never rotated and every subsequent request
continued to use the same failing credential.

Treat 403 the same as 402: immediately mark the current credential
exhausted and rotate to the next pool entry, since a Forbidden response
will not resolve itself with a retry.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
YueLich 2026-04-12 12:30:02 +03:00 committed by Teknium
parent 461899894e
commit 6fcaf5ebc2

View file

@ -5303,7 +5303,7 @@ class AIAgent:
effective_reason = FailoverReason.billing
elif status_code == 429:
effective_reason = FailoverReason.rate_limit
elif status_code == 401:
elif status_code in (401, 403):
effective_reason = FailoverReason.auth
if effective_reason == FailoverReason.billing: