fix(session): retry 5xx server errors even when isRetryable is unset (#22511)

This commit is contained in:
Kit Langton
2026-04-15 20:58:48 -04:00
committed by GitHub
parent a147ad68e6
commit 4ca809ef4e
2 changed files with 45 additions and 1 deletions

View File

@@ -56,7 +56,10 @@ export namespace SessionRetry {
// context overflow errors should not be retried
if (MessageV2.ContextOverflowError.isInstance(error)) return undefined
if (MessageV2.APIError.isInstance(error)) {
if (!error.data.isRetryable) return undefined
const status = error.data.statusCode
// 5xx errors are transient server failures and should always be retried,
// even when the provider SDK doesn't explicitly mark them as retryable.
if (!error.data.isRetryable && !(status !== undefined && status >= 500)) return undefined
if (error.data.responseBody?.includes("FreeUsageLimitError")) return GO_UPSELL_MESSAGE
return error.data.message.includes("Overloaded") ? "Provider is overloaded" : error.data.message
}