fix(model-error-classifier): mark OpenAI server_error patterns as retryable (fixes #3799)

OpenAI streaming responses can surface mid-stream errors with type
'server_error' or with the prose message 'An error occurred while processing
your request'. Neither matched any entry in RETRYABLE_MESSAGE_PATTERNS, so
shouldRetryError returned false and the runtime-fallback / fallback-retry
code paths skipped retry. The result was that GPT-5.5 subagent (and main)
turns silently stalled until the stale timeout fired.

The maintainer's diagnosis on issue #3799 explicitly recommends adding
these two patterns to model-error-classifier.ts; this commit does exactly
that and adds two regression tests covering the JSON envelope and the
prose form.
This commit is contained in:
MoerAI
2026-05-08 18:31:54 +09:00
parent 69e7ab4723
commit c85d2f9bc8
2 changed files with 33 additions and 0 deletions
+28
View File
@@ -434,6 +434,34 @@ describe("model-error-classifier", () => {
//#then
expect(result).toBe(true)
})
test("treats OpenAI streaming server_error envelopes as retryable (issue #3799)", () => {
//#given: OpenAI surfaces its mid-stream error with type 'server_error'
const error = {
name: undefined,
message: "{\"error\":{\"type\":\"server_error\",\"message\":\"server_error\"}}",
}
//#when
const result = shouldRetryError(error)
//#then
expect(result).toBe(true)
})
test("treats the OpenAI prose 'An error occurred while processing' message as retryable (issue #3799)", () => {
//#given: the human-readable prose surfaced when OpenAI's stream fails
const error = {
name: undefined,
message: "An error occurred while processing your request. Please try again later.",
}
//#when
const result = shouldRetryError(error)
//#then
expect(result).toBe(true)
})
})
export {}
+5
View File
@@ -80,6 +80,11 @@ const RETRYABLE_MESSAGE_PATTERNS = [
"请求过于频繁", // "too many requests"
"暂时不可用", // "temporarily unavailable"
"服务不可用", // "service unavailable"
// OpenAI streaming server_error events surface either as a literal "server_error"
// type or as the prose error sentence below. Without these patterns subagent
// streams stall instead of being retried (issue #3799).
"server_error",
"an error occurred while processing",
]
/**