fix(agent): classify message-only 'overloaded' as server overload

Salvage of #14261 by @ms-alan — rebased onto current main, scoped to the
overloaded-classification fix, with a regression test that fails without it.
This commit is contained in:
Bartok9 2026-06-26 01:43:39 -04:00 committed by Teknium
parent 151ae1e937
commit 45ce35ed72
2 changed files with 26 additions and 0 deletions

View file

@ -347,6 +347,18 @@ class TestClassifyApiError:
result = classify_api_error(e)
assert result.reason == FailoverReason.overloaded
def test_message_only_overloaded_without_status_is_overloaded(self):
"""Some Anthropic-compatible proxies surface 'overloaded' in the
message with no 503/529 status_code. It must classify as overloaded
(transient backoff+retry), not unknown / credential rotation. (#14261)"""
e = MockAPIError(
"Anthropic API error: Overloaded - the service is temporarily overloaded"
) # no status_code
result = classify_api_error(e, provider="anthropic")
assert result.reason == FailoverReason.overloaded
assert result.retryable is True
assert result.should_rotate_credential is False
# ── 5xx that are actually request-validation errors ──
# Some OpenAI-compatible gateways (e.g. codex.nekos.me) return
# request-validation failures with a 5xx status. These are