From 7efebff189ddc4077b332e1552fff899ed387d28 Mon Sep 17 00:00:00 2001 From: David Brailovsky Date: Wed, 14 Oct 2026 11:14:38 +0200 Subject: [PATCH] fix(ai): retry gateway 'Unable to forward upstream stream' errors closes #10920 --- packages/ai/CHANGELOG.md | 1 + packages/ai/src/utils/retry.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index f7510bf47..9f5a4c73d 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -12,6 +12,7 @@ - Fixed Anthropic requests failing with a 400 when an error tool result contains images; the images are now replaced with a text note ([#10794](https://github.com/earendil-works/pi/issues/10794)) - Fixed OpenCode Go Gemini models failing with a 404 by moving OpenCode Zen and OpenCode Go to the `opencode.ai/inference` endpoints, and added Google Generative AI support to the OpenCode Go provider - Fixed OpenCode Go MiniMax M2.7 failing with "Model does not support this protocol" by using the Anthropic Messages API +- Fixed automatic retry not triggering for gateway `Unable to forward upstream stream` errors ([#10920](https://github.com/earendil-works/pi/issues/10920)) ## [1.2.0] - 2026-10-12 diff --git a/packages/ai/src/utils/retry.ts b/packages/ai/src/utils/retry.ts index 8f3128c19..ae8fb6af0 100644 --- a/packages/ai/src/utils/retry.ts +++ b/packages/ai/src/utils/retry.ts @@ -52,6 +52,9 @@ const RETRYABLE_PROVIDER_ERROR_PATTERN = buildProviderErrorPattern([ // "The upstream provider returned an error" (#10842). "provider.?returned.?(?:an.?)?error", "exceeded request buffer limit while retrying upstream", + // Gateway failure relaying the upstream response stream, sent as an OpenAI + // Responses `response.failed` event without an error code (#10920). + "unable to forward upstream", // Network, proxy, and fetch transport failures. This includes OpenAI Codex // raw-fetch failures such as "upstream connect", "connection refused", and