fix(runtime-fallback): match ZAI 'Limit Exhausted' quota errors (fixes #4207)
The ZAI (Zhipu) provider emits 'Weekly/Monthly Limit Exhausted. Your limit will reset at YYYY-MM-DD HH:MM:SS' when the coding-plan subscription quota is hit. None of the existing quota regex patterns (/quota.?exceeded/, /usage\s+limit/, /exhausted\s+your\s+capacity/, /credit\s+balance.*too\s+low/, etc.) match the 'Limit Exhausted' phrasing, so the runtime-fallback never fires and the user is stuck on the dead model. Add /limit\s+exhausted/i to both pattern lists that gate fallback dispatch: - RETRYABLE_ERROR_PATTERNS in constants.ts (text-pattern path used by extractStatusCode + retryable scan) - classifyErrorType quota_exceeded branch in error-classifier.ts (typed classification path used by isRetryableError) The pattern is intentionally narrow: it requires the literal token 'Limit' followed by whitespace then 'Exhausted'. It matches the ZAI weekly, monthly, and combined Weekly/Monthly variants but does not collide with unrelated phrases such as 'context limit' or 'rate limit' that already have their own dedicated patterns. Regression coverage added to quota-error-classifier.regression.test.ts: - 'Weekly/Monthly Limit Exhausted. Your limit will reset at 2026-05-20 15:43:27' -> quota_exceeded + retryable=true - 'Weekly Limit Exhausted. Your limit will reset at 2026-05-28 10:30:00' -> quota_exceeded + retryable=true Verification: 11/11 quota-error-classifier.regression.test.ts pass (was 9 pass + 2 fail pre-fix). Broader runtime-fallback suite goes from 135/196 pass to 137/198 pass (the 61 pre-existing failures are unrelated to this change and reproduce on a clean upstream/dev checkout). bun run typecheck clean.
This commit is contained in:
@@ -148,6 +148,7 @@ export function classifyErrorType(error: unknown): string | undefined {
|
||||
/payment.?required/i.test(message) ||
|
||||
/usage\s+limit/i.test(message) ||
|
||||
/credit\s+balance.*too\s+low/i.test(message) ||
|
||||
/limit\s+exhausted/i.test(message) ||
|
||||
/使用上限/.test(message) ||
|
||||
/达到.*限制/.test(message) ||
|
||||
/额度.*不足/.test(message) ||
|
||||
|
||||
Reference in New Issue
Block a user