The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(bot-mode): require status-code context for bare numeric classifier rules
kshitij6994851694a9
diff --git a/tests/tools/test_bot_failure_reasons.py b/tests/tools/test_bot_failure_reasons.pyindex 096b94ae33d..cab41308aef 100644--- a/tests/tools/test_bot_failure_reasons.py+++ b/tests/tools/test_bot_failure_reasons.py@@ -60,6 +60,14 @@ def test_closed_vocabulary_contains_every_code():("missing config: no provider block in config.yaml", fr.MISSING_CONFIG),("model 'gpt-9' not found", fr.MODEL_UNAVAILABLE),("The model `foo-bar` does not exist", fr.MODEL_UNAVAILABLE),+ ("model_not_found", fr.MODEL_UNAVAILABLE),+ ("status: 401 unauthorized", fr.PROVIDER_AUTH_OR_ACCESS),+ ("upstream server error", fr.PROVIDER_SERVER_ERROR),+ # bare numbers WITHOUT a status-code context must not classify —+ # they feed AUTO_RETRYABLE and a misfire could auto-retry a+ # permanent local failure (review finding on #93101).+ ("gate check failed: error at line 502 of module", fr.UNKNOWN),+ ("took 429 ms to fail", fr.UNKNOWN),("something inexplicable happened", fr.UNKNOWN),("", fr.UNKNOWN),(None, fr.UNKNOWN),diff --git a/tools/bot_failure_reasons.py b/tools/bot_failure_reasons.pyindex c278a9d8808..b8e57962f63 100644--- a/tools/bot_failure_reasons.py+++ b/tools/bot_failure_reasons.py@@ -76,21 +76,32 @@ _RULES: tuple[tuple[re.Pattern[str], str], ...] = ((re.compile(r"authentication_error|invalid api key"- r"|(?:error code:?\s*|status(?:\s*code)?:?\s*|\b)(?:401|403)\b",+ r"|(?:error code:?\s*|status(?:\s*code)?:?\s*|http\s*)(?:401|403)\b",re.IGNORECASE,),PROVIDER_AUTH_OR_ACCESS,),(- re.compile(r"\b402\b|out of funds|quota|balance", re.IGNORECASE),+ re.compile(+ r"(?:error code:?\s*|status(?:\s*code)?:?\s*|http\s*)402\b"+ r"|out of funds|quota|balance",+ re.IGNORECASE,+ ),PROVIDER_QUOTA_LIMIT,),(- re.compile(r"\b429\b|rate.?limit", re.IGNORECASE),+ re.compile(+ r"(?:error code:?\s*|status(?:\s*code)?:?\s*|http\s*)429\b|rate.?limit",+ re.IGNORECASE,+ ),PROVIDER_RATE_LIMIT,),(- re.compile(r"\b5\d{2}\b|server error|overloaded", re.IGNORECASE),+ re.compile(+ r"(?:error code:?\s*|status(?:\s*code)?:?\s*|http\s*)5\d{2}\b"+ r"|server error|overloaded",+ re.IGNORECASE,+ ),PROVIDER_SERVER_ERROR,),(