Skip to content

fix(agent-runtime): do not treat billing or disk quota as rate limit - #1876

Merged
vastsa merged 4 commits into
vastsa:mainfrom
xpeng5278-web:fix/quota-billing-misclassify
Oct 28, 2026
Merged

vastsa merged 4 commits into
vastsa:mainfrom
xpeng5278-web:fix/quota-billing-misclassify

Conversation

@xpeng5278-web

@xpeng5278-web xpeng5278-web commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1875

What

  • Keep generic quota out of the throughput rate-limit matcher.
  • Classify explicit billing/account exhaustion codes and messages as terminal PROVIDER_ERROR before generic HTTP 429 handling. This includes insufficient_quota, credit_balance_exhausted, organization/project spend-limit codes, organization usage limits, and billing/spending/credit/disk quota messages.
  • Keep throughput signals such as rate limit, too many requests, throttling, and generic quota exceeded wording retryable.

Why

Account and filesystem exhaustion do not recover by backing off. The previous exception let common insufficient_quota billing responses enter the same retry loop, including when returned with HTTP 429.

How tested

  • packages/agent-runtime: vitest run → 1520/1520 passed.
  • tsc -p packages/agent-runtime/tsconfig.json --noEmit passed.
  • Added classifier and retry-flow regressions for the full billing 429 shape, structured exhaustion codes, and preserved throughput retries.

Scope

Runtime error classification, its retry-flow tests, and the synchronized runtime error/E2E specifications.

A bare /quota/ match classified spending, credit, billing, and disk
exhaustion as PROVIDER_RATE_LIMITED. The runtime then backed off and
retried failures that cannot recover. Keep insufficient_quota and real
throttle wording retryable, and mark those account and filesystem
quotas terminal.

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reported problem is real, but this exception leaves the same retry loop in a common billing case. The !insufficient_quota guard skips EXHAUSTED_QUOTA_PATTERN whenever that token appears, and the new test explicitly expects insufficient_quota: Billing quota exceeded to remain retryable. OpenAI's current error-code guide says billing errors can still use the broader insufficient_quota type and that retrying billing, spend, or quota errors does not restore access: https://developers.openai.com/api/docs/guides/error-codes. Please classify explicit billing/spend/credit exhaustion as terminal even when the provider includes insufficient_quota, and add a regression using the full billing error shape. Keep recognized throughput throttles retryable. Thanks for the focused change and clear repro; this edge needs to be corrected before the fix closes the reported retry loop.

vastsa commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Re-reviewed the current head against current main (the billing exception is still present). This is a code-level root-cause blocker, independent of CI: EXHAUSTED_QUOTA_PATTERN && !/insufficient_quota/ still retries insufficient_quota: Billing quota exceeded, and the new test enshrines that behavior. Please let explicit billing/spending/credit exhaustion win even when insufficient_quota is included, with a regression for that combined error. Leaving this open for the focused correction.

Provider billing and account exhaustion can arrive as HTTP 429 and use
the insufficient_quota type. Classify explicit exhaustion before the
generic 429 retry path while preserving retries for throughput limits.

Add classifier and retry-flow regressions and sync the runtime specs.

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against the latest main. The retry defect is real; explicit billing/account exhaustion now remains terminal before generic 429 handling, while throughput limits remain retryable. The regression covers the full billing 429 shape and confirms the request is attempted only once. Package tests and typecheck pass.

@vastsa
vastsa merged commit 072068d into vastsa:main Oct 28, 2026
6 checks passed

vastsa commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Thanks for the focused fix. I verified the billing retry defect and merged the PR with a small completion: explicit insufficient_quota and billing/spend exhaustion now stay terminal even on HTTP 429, while throughput rate limits remain retryable. The regression tests confirm the billing response is attempted once, and the runtime specs now describe the distinction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Billing/disk "quota" wording is classified as PROVIDER_RATE_LIMITED (retried ~10×)

2 participants