Repository navigation
fix(provider): classify gateway quota exhaustion and 402 as non-retryable - #378
Merged
Merged
Conversation
filipeforattini
enabled auto-merge (squash)
September 23, 2026 06:04
This was referenced Sep 23, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports the ideas from upstream opencode 4a27842 and 6a30741 to both runtimes.
@reddb-io/redcode-llm: newisQuotaFailure/isContentPolicyFailureclassifiers. Quota = HTTP 402, a quota code (insufficient_quota,usage_not_included,billing_error,usage_limit*,insufficient_credits, ZenFreeUsageLimitError/GoUsageLimitError/CreditLimitExceeded) wherever a provider or router puts it (including OpenRoutermetadata.rawand Zen[code]labels), or quota/credits wording on a 429. Content policy = provider codes (content_filter,ResponsibleAIPolicyViolation,content_policy_violation, ...).RequestExecutor(v2): 402 and gateway caps becomeQuotaExceeded(not retried) instead ofUnknownProvider/RateLimit.SessionRetry(core, both runtimes): quota and content-policy failures are never retried, even when the SDK marks a 429 retryable or the body says "try again". A 4xx other than 408/409/429 is only promoted to retryable by transport failures, so a gateway's substitutedserver_erroron a 400 is no longer retried. Router-reported reasons (quota_exhaustedwith retry-at) keep router semantics.ProviderError.parseAPICallError/parseStreamError: quota failures are non-retryable and the message says the account's quota, credits or free-tier limit is exhausted.Tests
packages/llm/test/provider-error.test.ts,packages/llm/test/executor.test.tspackages/core/test/session-retry.test.tspackages/redcode/test/session/retry.test.ts(the FreeUsageLimitError/GoUsageLimitError case now expects no retry)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.