← Back to PRs

#6014: Agents: improve quota exhaustion fallback detection

by erain open 2026-02-01 06:12 View on GitHub →
agents
## Summary - expand failover classification to catch quota/capacity exhaustion variants and insufficient_quota - add tests to cover the new classification paths ## Testing - pnpm vitest src/agents/pi-embedded-helpers.classifyfailoverreason.test.ts --maxWorkers=1 - pnpm vitest src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts --maxWorkers=1 <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR broadens the heuristic error classification in `src/agents/pi-embedded-helpers/errors.ts` to recognize more quota/capacity exhaustion phrases and to treat `insufficient_quota` as a billing signal. It also adds Vitest coverage to ensure `classifyFailoverReason` and `isBillingErrorMessage` exercise these new branches. Overall the change fits the existing design: `classifyFailoverReason` is a thin wrapper over message-pattern matchers used to decide whether a failure should be treated as retryable/failoverable and why. <h3>Confidence Score: 3/5</h3> - This PR is likely safe to merge, but the expanded substring heuristics could cause some new misclassifications depending on upstream error text. - Changes are localized to string-pattern matching plus targeted tests. Main risk is behavioral: newly added broad substrings (e.g., "quota reset") may match unrelated errors, and mapping `insufficient_quota` to billing may not align with how some providers use that code. - src/agents/pi-embedded-helpers/errors.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs