Repository navigation
feat(driver): surface structured rate-limit/credits errors from SDK message stream (#732) - #735
Merged
admarble merged 3 commits intoJun 21, 2026
Conversation
…tream (#732) Read the SDK's rate_limit_event + assistant error signals at the ClaudeCodeDriver stream chokepoint instead of discarding them and guessing rate limits via regex-on-stderr. - Add RateLimitError (retryable) and BillingError (non-retryable) SequantError subclasses carrying resetsAt, overageDisabledReason, and (SDK >=0.3.181) canUserPurchaseCredits / hasChargeableSavedPaymentMethod. - Driver captures rate_limit_event / assistant.error / api_retry and builds the typed error; propagate via AgentPhaseResult.structuredError -> PhaseResult.structuredError. - phase-executor prefers structuredError over stderr classification and skips the misleading no-MCP retry (#592) for billing failures. - Stderr-regex classifier retained as the subprocess (run.ts) fallback. Entire-Checkpoint: dde8c86f8a63
8 tasks
…ling guard var (#732) Addresses the non-blocking QA suggestions on PR #735: - ClaudeCodeDriver catch block now builds and attaches structuredError from captured rate_limit_event / assistant.error signals, so a mid-stream throw after a rejected rate-limit/billing event surfaces the real cause instead of the raw thrown message. Abort/timeout is still handled first, so a genuine timeout is never masked. - Rename the local `isBillingFailure` guard in phase-executor to `failureIsBilling` to avoid name overlap with the exported isBillingFailure(info) predicate. - Add driver tests for both catch-path branches (structured cause vs abort-wins). Entire-Checkpoint: c4ff63eb64f0
… over transient throttle (#732) QA follow-up addressing two gaps surfaced in re-review: 1. formatResetTime now renders "MM-DD HH:MM" when a reset falls on a different local calendar day, and bare "HH:MM" when it is today. A seven_day rate-limit window can reset days out; the previous bare HH:MM read as "later today" and misled the user. 2. buildStructuredError now lets a billing_error assistant signal win over a co-occurring transient rate_limit_event, so a non-retryable billing failure is never downgraded to a retryable RateLimitError (which would wrongly re-enable the retry / MCP-fallback path). When the rate_limit_event is itself a billing failure, its richer metadata (canUserPurchaseCredits, etc.) is preserved. Adds same-day/multi-day reset tests and a billing-precedence driver test. Entire-Checkpoint: a023631cff45
3 tasks
Closed
9 tasks
admarble
added a commit
that referenced
this pull request
Sep 9, 2026
…ling guard var (#732) Addresses the non-blocking QA suggestions on PR #735: - ClaudeCodeDriver catch block now builds and attaches structuredError from captured rate_limit_event / assistant.error signals, so a mid-stream throw after a rejected rate-limit/billing event surfaces the real cause instead of the raw thrown message. Abort/timeout is still handled first, so a genuine timeout is never masked. - Rename the local `isBillingFailure` guard in phase-executor to `failureIsBilling` to avoid name overlap with the exported isBillingFailure(info) predicate. - Add driver tests for both catch-path branches (structured cause vs abort-wins). Entire-Checkpoint: c4ff63eb64f0
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
rate_limit_event(SDKRateLimitInfo) and assistanterrorsignals, but sequant dropped them at theClaudeCodeDriverstream chokepoint and guessed rate limits via regex-on-stderr. The driver now reads these signals and constructs a typedRateLimitError(retryable) orBillingError(non-retryable).AgentPhaseResult.structuredError→PhaseResult.structuredError, so a failed phase names the real cause ("Out of credits — purchasable", "Rate limited — resets at HH:MM") instead of the generic, misleadingPhase failed with MCP enabled, retrying without MCP...noise (fix(run): pre-flight guard misses in_progress issues already merged on GitHub (gap in #305/#423) #592).run.ts) fallback, so non-SDK classification is unchanged.Pre-PR AC Verification
rate_limit_event+ assistanterrorinstead of discardingclaude-code.tscapture vars +claude-code.test.tsRateLimitError/BillingErrorextendSequantError, carryresetsAt+overageDisabledReason, correctisRetryableerrors.ts;rate-limit-errors.test.tserror: structuredError.message;phase-executor.test.tsBillingErrorguard at MCP fallback;phase-executor.test.ts(2 tests)error-types.test.ts+error-capture.test.tsunchanged & greenclaude-code.test.ts(rate_limit_event, assistant.error, api_retry)canUserPurchaseCredits/hasChargeableSavedPaymentMethod) with graceful gatingformatRateLimitMessage;rate-limit-errors.test.tssdk.d.tsexposes the 0.3.181 fields)Test plan
npm run build— passes (tsc clean)npm run lint— passes (0 warnings)rate-limit-errors,claude-code,phase-executor,error-types,error-capture— 218 passedCloses #732
🤖 Generated with Claude Code