Skip to content

fix: mark response body network errors as retryable - #19890

Merged
gr2m merged 1 commit into
mainfrom
codex/fix-response-body-network-errors
Aug 27, 2026
Merged

gr2m merged 1 commit into
mainfrom
codex/fix-response-body-network-errors

Conversation

@gr2m

@gr2m gr2m commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

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.

@gr2m
gr2m merged commit 90192f1 into main Aug 27, 2026
53 checks passed
@gr2m
gr2m deleted the codex/fix-response-body-network-errors branch August 27, 2026 23:02
@gr2m gr2m added the backport Admins only: add this label to a pull request in order to backport it to the prior version label Aug 27, 2026
github-actions Bot added a commit that referenced this pull request Aug 27, 2026
@github-actions github-actions Bot removed the backport Admins only: add this label to a pull request in order to backport it to the prior version label Aug 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Backport to release-v6.0 created but has conflicts: #19896

gr2m added a commit that referenced this pull request Aug 27, 2026
This is a backport of #19890 to the release-v6.0 branch. FYI @gr2m

The response-handler test conflict was resolved by retaining the
release-v6.0 test suite and adding only the new EventSource regression
test.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Published in:

Package Version
ai 7.0.84 github npm
@ai-sdk/alibaba 2.0.38 github npm
@ai-sdk/amazon-bedrock 5.0.67 github npm
@ai-sdk/angular 3.0.84 github npm
@ai-sdk/anthropic 4.0.45 github npm
@ai-sdk/anthropic-aws 2.0.37 github npm
@ai-sdk/assemblyai 3.0.33 github npm
@ai-sdk/azure 4.0.53 github npm
@ai-sdk/baseten 2.1.18 github npm
@ai-sdk/black-forest-labs 2.0.34 github npm
@ai-sdk/bytedance 2.0.36 github npm
@ai-sdk/cartesia 3.0.28 github npm
@ai-sdk/cerebras 3.0.40 github npm
@ai-sdk/code-mode 1.0.41 github npm
@ai-sdk/cohere 4.0.34 github npm
@ai-sdk/deepgram 3.1.4 github npm
@ai-sdk/deepinfra 3.0.40 github npm
@ai-sdk/deepseek 3.0.36 github npm
@ai-sdk/elevenlabs 3.0.34 github npm
@ai-sdk/fal 3.0.34 github npm
@ai-sdk/fireworks 3.0.43 github npm
@ai-sdk/fish-audio 3.0.11 github npm
@ai-sdk/gateway 4.0.68 github npm
@ai-sdk/gladia 3.0.33 github npm
@ai-sdk/gmicloud 3.0.11 github npm
@ai-sdk/google 4.0.57 github npm
@ai-sdk/google-vertex 5.0.69 github npm
@ai-sdk/groq 4.0.34 github npm
@ai-sdk/harness 1.0.93 github npm
@ai-sdk/harness-acp 1.0.31 github npm
@ai-sdk/harness-claude-code 1.0.97 github npm
@ai-sdk/harness-cline 1.0.20 github npm
@ai-sdk/harness-codex 1.0.95 github npm
@ai-sdk/harness-cursor 1.0.6 github npm
@ai-sdk/harness-deepagents 1.0.93 github npm
@ai-sdk/harness-fx 1.0.6 github npm
@ai-sdk/harness-grok-build 1.0.30 github npm
@ai-sdk/harness-opencode 1.0.95 github npm
@ai-sdk/harness-pi 1.0.95 github npm
@ai-sdk/huggingface 2.0.40 github npm
@ai-sdk/hume 3.0.33 github npm
@ai-sdk/klingai 4.0.35 github npm
@ai-sdk/langchain 3.0.84 github npm
@ai-sdk/llamaindex 3.0.84 github npm
@ai-sdk/lmnt 3.0.33 github npm
@ai-sdk/luma 3.0.34 github npm
@ai-sdk/mcp 2.0.40 github npm
@ai-sdk/minimax 3.0.21 github npm
@ai-sdk/mistral 4.0.36 github npm
@ai-sdk/moonshotai 3.0.42 github npm
@ai-sdk/open-responses 2.0.35 github npm
@ai-sdk/openai 4.0.51 github npm
@ai-sdk/openai-compatible 3.0.40 github npm
@ai-sdk/otel 1.0.84 github npm
@ai-sdk/perplexity 4.0.35 github npm
@ai-sdk/policy-opa 1.0.84 github npm
@ai-sdk/prodia 2.0.34 github npm
@ai-sdk/provider-utils 5.0.33 github npm
@ai-sdk/quiverai 2.0.33 github npm
@ai-sdk/react 4.0.87 github npm
@ai-sdk/replicate 3.0.34 github npm
@ai-sdk/revai 3.0.33 github npm
@ai-sdk/rsc 3.0.84 github npm
@ai-sdk/sandbox-just-bash 1.0.93 github npm
@ai-sdk/sandbox-vercel 1.0.93 github npm
@ai-sdk/svelte 5.0.84 github npm
@ai-sdk/togetherai 3.0.41 github npm
@ai-sdk/tui 1.0.85 github npm
@ai-sdk/valibot 3.0.33 github npm
@ai-sdk/voyage 2.0.33 github npm
@ai-sdk/vue 4.0.84 github npm
@ai-sdk/workflow 2.0.14 github npm
@ai-sdk/workflow-harness 1.0.93 github npm
@ai-sdk/xai 4.0.49 github npm
@ai-sdk/zai 3.0.2 github npm

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