fix: add universal billing error detection for router mode

- Add HTTP 402 and 'insufficient credits' patterns to error classification
- Detect provider billing errors in both exception and message content paths
This commit is contained in:
ajmallesh
2026-01-16 11:18:27 -08:00
parent cd04c7a6d2
commit 9606ffcf70
2 changed files with 5 additions and 0 deletions
+2
View File
@@ -211,7 +211,9 @@ export function classifyErrorForTemporal(error: unknown): TemporalErrorClassific
// === BILLING ERRORS (Retryable with long backoff) ===
// Anthropic returns billing as 400 invalid_request_error
// Human can add credits OR wait for spending cap to reset (5-30 min backoff)
// 402 is HTTP "Payment Required" - universal across providers (OpenRouter, etc.)
if (
message.includes('402') ||
message.includes('billing_error') ||
message.includes('credit balance is too low') ||
message.includes('insufficient credits') ||