fix(model-fallback): add HTTP statusCode check for GLM rate limit fallback#3773
Open
cailgarrisk-collab wants to merge 1 commit intocode-yeongyu:devfrom
Open
Conversation
…lback isRetryableModelError() now checks the HTTP status code (429/503/529) in addition to existing message pattern matching. This ensures rate limit errors trigger model fallback regardless of error message format or language (e.g., Chinese GLM errors). Changes: - ErrorInfo interface extended with statusCode?: number - isRetryableModelError() checks statusCode after STOP patterns, before message pattern fallback - extractErrorStatusCode() added to error-classifier.ts (supports statusCode, status, code, response.status fields) - GLM-specific STOP patterns added: daily call limit, in arrears, fair use policy, recharge and try — these prevent quota/billing 429s from being treated as transient rate limits - statusCode propagated through tryFallbackRetry and manager.ts 400 intentionally excluded from statusCode check (permanent client error).
Contributor
|
Thank you for your contribution! Before we can merge this PR, we need you to sign our Contributor License Agreement (CLA). To sign the CLA, please comment on this PR with: This is a one-time requirement. Once signed, all your future contributions will be automatically accepted. I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
There was a problem hiding this comment.
No issues found across 5 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Correctly implements status code checks with proper precedence to avoid regressions on quota errors; comprehensive tests provided.
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
isRetryableModelError()only checked error message strings for rate-limit patterns, missing cases where the provider returns HTTP 429 without matching text (e.g., Chinese GLM/Z.ai messages like"请求频率过高"). This fix adds HTTP status code checking as a parallel detection path.Changes
src/shared/model-error-classifier.tsErrorInfointerface: addedstatusCode?: numberisRetryableModelError(): checksstatusCode(429/503/529) after STOP patterns and before message pattern fallback — stops prevent quota/billing 429s from retryingSTOP_MESSAGE_PATTERNS: added GLM/Z.ai-specific quota patterns:"daily call limit","in arrears","fair use policy","recharge and try","usage limit reached for"src/features/background-agent/error-classifier.tsextractErrorStatusCode()— extracts HTTP status from error objects supporting:statusCode,status,code,response.status(number and string formats)src/features/background-agent/fallback-retry-handler.tstryFallbackRetry()errorInfoacceptsstatusCode?: numbersrc/features/background-agent/manager.tserrorInfoconstruction sites now extractstatusCodeviaextractErrorStatusCode()tryFallbackRetry+handleSessionErrorEventsignatures updatedsrc/shared/model-error-classifier.test.tsVerification
Precedence Chain
STOP patterns (quota, arrears, fair-use) always win over statusCode 429.
Need help on this PR? Tag
@codesmithwith what you need.Summary by cubic
Fixes model fallback detection by checking HTTP status codes so GLM/Z.ai rate limits are caught even with non-English or missing messages. Prevents retries on quota/billing errors via new STOP patterns.
isRetryableModelError()checksstatusCode429/503/529 before message matching; STOP patterns still win.extractErrorStatusCode()and passedstatusCodethrough fallback and manager handlers.Written for commit 61d2f11. Summary will update on new commits.