Skip to content

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

Merged
kitlangton merged 3 commits intodevfrom
fix/retry-5xx-errors
Apr 16, 2026
Merged

fix(session): retry 5xx server errors even when isRetryable is unset#22511
kitlangton merged 3 commits intodevfrom
fix/retry-5xx-errors

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Summary

  • Treat 5xx status codes as retryable in the session retry policy, even when the provider SDK doesn't explicitly set isRetryable: true
  • Most LLM provider SDKs (Anthropic, OpenAI) don't mark plain 500/502/503 responses as retryable, so they were surfacing as terminal failures instead of being retried
  • Adds tests for 500, 502, 503 retry and confirms 4xx errors are still not retried

Context

The AI SDK's built-in retry (maxRetries) was disabled in Dec 2025 when the custom Effect-based retry policy took over. The old maxRetries: 10 handled 5xx errors automatically, but the new custom retryable() function only checked isRetryable (which providers don't set for most 5xx) and text-matched rate limit patterns. This left a gap where transient 500s would fail immediately.

Most LLM provider SDKs don't set isRetryable on plain 500/502/503
responses, so they fell through the retry policy and surfaced as
terminal failures. Treat any 5xx status code as retryable since
these are transient server-side errors.
@kitlangton kitlangton marked this pull request as ready for review April 15, 2026 00:41
@kitlangton kitlangton enabled auto-merge (squash) April 16, 2026 00:52
@kitlangton kitlangton merged commit 4ca809e into dev Apr 16, 2026
10 checks passed
@kitlangton kitlangton deleted the fix/retry-5xx-errors branch April 16, 2026 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant