fix(model-fallback): add HTTP statusCode check for GLM rate limit fallback
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).
This commit is contained in:
@@ -46,6 +46,7 @@ import {
|
||||
isAbortedSessionError,
|
||||
extractErrorName,
|
||||
extractErrorMessage,
|
||||
extractErrorStatusCode,
|
||||
getSessionErrorMessage,
|
||||
isRecord,
|
||||
} from "./error-classifier"
|
||||
@@ -749,6 +750,7 @@ The fallback retry session is now created and can be inspected directly.
|
||||
const errorInfo = {
|
||||
name: extractErrorName(error),
|
||||
message: extractErrorMessage(error),
|
||||
statusCode: extractErrorStatusCode(error),
|
||||
}
|
||||
if (await this.tryFallbackRetry(existingTask, errorInfo, "promptAsync.launch")) {
|
||||
return
|
||||
@@ -1079,6 +1081,7 @@ The fallback retry session is now created and can be inspected directly.
|
||||
const errorInfo = {
|
||||
name: extractErrorName(error),
|
||||
message: extractErrorMessage(error),
|
||||
statusCode: extractErrorStatusCode(error),
|
||||
}
|
||||
if (await this.tryFallbackRetry(existingTask, errorInfo, "promptAsync.resume")) {
|
||||
return
|
||||
@@ -1199,6 +1202,7 @@ The fallback retry session is now created and can be inspected directly.
|
||||
const errorInfo = {
|
||||
name: extractErrorName(assistantError),
|
||||
message: extractErrorMessage(assistantError),
|
||||
statusCode: extractErrorStatusCode(assistantError),
|
||||
}
|
||||
void this.tryFallbackRetry(task, errorInfo, "message.updated").catch((error) => {
|
||||
log("[background-agent] Error handling message.updated fallback retry:", {
|
||||
@@ -1444,7 +1448,7 @@ The fallback retry session is now created and can be inspected directly.
|
||||
|
||||
private async handleSessionErrorEvent(args: {
|
||||
task: BackgroundTask
|
||||
errorInfo: { name?: string; message?: string }
|
||||
errorInfo: { name?: string; message?: string; statusCode?: number }
|
||||
errorName: string | undefined
|
||||
errorMessage: string | undefined
|
||||
}): Promise<void> {
|
||||
@@ -1532,7 +1536,7 @@ The fallback retry session is now created and can be inspected directly.
|
||||
|
||||
private tryFallbackRetry(
|
||||
task: BackgroundTask,
|
||||
errorInfo: { name?: string; message?: string },
|
||||
errorInfo: { name?: string; message?: string; statusCode?: number },
|
||||
source: string,
|
||||
): Promise<boolean> {
|
||||
const previousSessionID = task.sessionId
|
||||
|
||||
Reference in New Issue
Block a user