SIGN IN SIGN UP

fix: mark response body network errors as retryable (#19890)

## Background

Transient Undici failures can occur after fetch has returned successful
HTTP response headers, while the JSON or SSE body is still being read.
These failures are currently wrapped with the HTTP 200 status and
treated as non-retryable, so non-streaming language model and Gateway
calls do not use their configured retry budget.

## Changes

- recognize retryable Bun and Undici network codes throughout an error
cause chain
- preserve APICallError request and response context when marking a
nested transport failure retryable
- wrap EventSource response-body failures with the same API call context
used for non-streaming responses
- preserve the actual HTTP status while explicitly carrying retryability
through Gateway error conversion
- add transport-boundary, EventSource, cause-cycle, and Gateway
regression coverage

This intentionally does not retry partial streamText model attempts.
Restarting a model after output has already been exposed requires
separate semantics for abandoned output and exactly-once tool execution.

## Testing

- provider-utils full Node and Edge suites: 827 tests passed in each
runtime
- Gateway full Node suite: 540 tests passed
- Gateway full Edge suite: 532 tests passed, 8 skipped
- pnpm check
- pnpm type-check:full
- pnpm --filter @ai-sdk/gateway... build

## Backports

Recommended for release-v6.0 and release-v5.0 after this PR merges. The
issue was reproduced on both release lines, and this is an internal
patch-level retry classification fix.

## Related

Refs #9775

Extracts the safe transport-error portion of #18062 without its
partial-stream replay behavior.
G
Gregor Martynus committed
90192f19a1348eec52a482a6b33118f1768790b7
Parent: 5021768
Committed by GitHub <noreply@github.com> on 8/27/2026, 11:02:44 PM