Skip to content

fix(coderd/x/chatd): retry quota 429s#26200

Draft
johnstcn wants to merge 2 commits into
mainfrom
cian/codagt-495-rate-limit-quota-429
Draft

fix(coderd/x/chatd): retry quota 429s#26200
johnstcn wants to merge 2 commits into
mainfrom
cian/codagt-495-rate-limit-quota-429

Conversation

@johnstcn

@johnstcn johnstcn commented Jun 9, 2026

Copy link
Copy Markdown
Member

Provider 429 responses that mention quota or billing were classified as non-retryable usage limits before the rate-limit rule could run, which suppressed retries for Gemini and Azure OpenAI rate limits.

Treat broad quota and billing prose as rate-limit retryable when the provider returns HTTP 429, while preserving insufficient_quota as a terminal usage-limit signal for OpenAI billing exhaustion. Structured provider details are included in usage-limit matching so response-body error codes are classified consistently.

Refs https://linear.app/codercom/issue/CODAGT-495/broad-quota-pattern-suppresses-retries-on-provider-429-rate-limit

Implementation plan and review context

Plan: /home/coder/.coder/plans/PLAN-e03d6baf-4aad-48dc-9868-c5d836c6fae4.md

Deep review found that OpenAI documents 429 - You exceeded your current quota, please check your plan and billing details as a terminal billing exhaustion case, while Google Gemini and Azure OpenAI document 429 quota wording as retryable rate limiting. The implementation therefore gates broad quota/billing text on non-429 status while keeping the explicit insufficient_quota code terminal at any status.

Generated by Coder Agents on behalf of @johnstcn.

@johnstcn johnstcn self-assigned this Jun 9, 2026
@linear-code

linear-code Bot commented Jun 9, 2026

Copy link
Copy Markdown

CODAGT-495

@johnstcn

johnstcn commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

/coder-agents-review

@coder-agents-review

coder-agents-review Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Chat: Review in progress | View chat
Requested: 2026-06-09 22:43 UTC by @johnstcn
Spend: $17.66 / $100.00

deep-review v0.7.1 | Round 2 | ace1a5a..0fa6020

Status: Panel review (4 reviewers)

Last posted: Round 1, 5 findings (1 P3, 3 Nit, 1 Note), COMMENT. Review

Finding inventory

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 Nit Open signals.go:72 "insufficient_quota" in usageLimitPatterns is dead weight R1 Hisoka Nit, Mafuuu Nit, Gon P3, Leorio Nit, Ryosuke Nit, Meruem Nit, Knov Nit Yes
CRF-2 Nit Open signals.go:75-78 Comment bloat: second sentence describes classify.go behavior, not this declaration R1 Gon P2 Yes
CRF-3 P3 Open classify.go:207 Non-429 structured-detail path untested R1 Knov Yes
CRF-4 Nit Open classify.go:231-232 "Explicit usage exhaustion codes" is vague; name insufficient_quota R1 Leorio Yes
CRF-5 Note Open classify.go:207 Structured-detail matching is asymmetric (usage-limit only) R1 Hisoka, Mafuuu, Gon, Leorio, Ryosuke, Meruem, Kite, Knov Yes

Round log

Round 1

Panel: Bisky, Hisoka, Mafu-san, Mafuuu, Pariston, Gon, Leorio, Ging-Go, Chopper, Ryosuke, Meruem, Kite, Knov. Netero: no findings. 1 P3, 3 Nit, 1 Note. Reviewed against ace1a5a..3957b18.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Precise fix for a real provider interop problem. The two-tier pattern split (usageLimitAnyStatusPatterns vs usageLimitPatterns gated on non-429) uses HTTP semantics as the disambiguation signal, which is the right abstraction. High test density (88.7%) with positive and negative coverage for the behavioral change, including realistic Gemini, Azure OpenAI, and structured provider error shapes. The relocated QuotaWith429Status test was expanded with a structured-error variant, not dropped.

1 P3, 3 Nit, 1 Note. The P3 is a test gap for non-429 structured-detail matching.

Hisoka: "Clean fight. The 429 gate is sound, the insufficient_quota carve-out is precise, and the test matrix covers the real provider error shapes."

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/x/chatd/chaterror/signals.go Outdated
Comment thread coderd/x/chatd/chaterror/signals.go Outdated
Comment thread coderd/x/chatd/chaterror/classify.go
Comment thread coderd/x/chatd/chaterror/classify.go Outdated
deadline := errors.Is(err, context.DeadlineExceeded) || strings.Contains(lower, "context deadline exceeded")
overloadedMatch := statusCode == 529 || containsAny(lower, overloadedPatterns...)
usageLimitMatch := containsAny(lower, usageLimitPatterns...)
usageLimitText := lower + "\n" + strings.ToLower(structured.detail)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note [CRF-5] structured.detail is now part of usage-limit matching but not other signals.

Other signal matchers (configMatch, authStrong, rateLimitMatch, etc.) still check only lower. This is correct scoping: rate limits have 429, auth has 401/403, and config patterns describe model names that appear in the error chain. Usage limits lack a dedicated HTTP code, so body text is their primary signal. Eight reviewers noted this independently and all concurred the asymmetry is intentional. Worth keeping in mind if future providers surface critical signals only in their response body. (Hisoka, Mafuuu, Gon, Leorio, Ryosuke, Meruem, Kite, Knov)

🤖

@johnstcn

johnstcn commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

/coder-agents-review

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.

1 participant