Skip to content

The agent that grows with you

fix(agent): classify Novita 'server overload' 429 as overloaded

KeyArgo43ecad8fe685
diff --git a/agent/error_classifier.py b/agent/error_classifier.py
index 505244c541f..f7d7f47cf19 100644
--- a/agent/error_classifier.py
+++ b/agent/error_classifier.py
@@ -125,6 +125,7 @@ _RATE_LIMIT_PATTERNS = (
_OVERLOADED_PATTERNS = (
"overloaded", "temporarily overloaded", "service is temporarily overloaded",
"service may be temporarily overloaded", "server is overloaded", "server overloaded",
+ "server overload", "server_overload",
"service overloaded", "service is overloaded", "upstream overloaded", "currently overloaded",
"at capacity", "over capacity",
)
diff --git a/tests/agent/test_error_classifier.py b/tests/agent/test_error_classifier.py
index d5d0ca6d50d..f979e00bc5e 100644
--- a/tests/agent/test_error_classifier.py
+++ b/tests/agent/test_error_classifier.py
@@ -511,6 +511,24 @@ class TestClassifyApiError:
assert result.retryable is True
assert result.should_rotate_credential is False
+ def test_429_novita_server_overload_is_overloaded_not_rate_limit(self):
+ """Novita returns HTTP 429 with message 'server overload, please try
+ again later' and error type 'server_overload' for a genuinely busy
+ server (not a credential quota). Neither phrase was in the overload
+ tuple, so it fell through to rate_limit and would rotate the credential
+ / fall back early instead of retrying the same key. (#106205)"""
+ e = MockAPIError(
+ "server overload, please try again later",
+ status_code=429,
+ body={"error": {"message": "server overload, please try again later",
+ "type": "server_overload"}},
+ )
+ result = classify_api_error(e, provider="custom:novita")
+ assert result.reason == FailoverReason.overloaded
+ assert result.retryable is True
+ assert result.should_fallback is False
+ assert result.should_rotate_credential is False
+
def test_429_normal_rate_limit_still_rotates(self):
"""Guard: a genuine 429 rate limit (no overload language) must still
classify as rate_limit and rotate the credential. (#14038)"""