From e98f287ee498e0116546f4e9aa083fdec9793cd2 Mon Sep 17 00:00:00 2001 From: David Brailovsky Date: Thu, 17 Sep 2026 12:01:39 +0200 Subject: [PATCH] fix(ai): retry Azure peak-load capacity errors Closes #9669 --- packages/ai/CHANGELOG.md | 1 + packages/ai/src/utils/retry.ts | 1 + packages/ai/test/retry.test.ts | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index 1d175294e..00fefb699 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -25,6 +25,7 @@ - Fixed OpenAI-compatible Responses errors to identify the actual provider instead of always labeling them as OpenAI errors ([#9298](https://github.com/earendil-works/pi/issues/9298)). - Fixed Baseten requests to send session-affinity headers from `sessionId` for automatic prompt-cache routing ([#9629](https://github.com/earendil-works/pi/issues/9629)). - Fixed retry classification for Cloudflare 520 responses ([#9627](https://github.com/earendil-works/pi/issues/9627)). +- Fixed retry classification for transient Azure peak-load capacity errors ([#9669](https://github.com/earendil-works/pi/issues/9669)). ## [0.85.1] - 2026-09-05 diff --git a/packages/ai/src/utils/retry.ts b/packages/ai/src/utils/retry.ts index 89c750ed6..ffe1e068d 100644 --- a/packages/ai/src/utils/retry.ts +++ b/packages/ai/src/utils/retry.ts @@ -26,6 +26,7 @@ const NON_RETRYABLE_PROVIDER_LIMIT_ERROR_PATTERN = buildProviderErrorPattern([ const RETRYABLE_PROVIDER_ERROR_PATTERN = buildProviderErrorPattern([ // Generic provider load, HTTP status, and server-side transient failures. "overloaded", + "currently experiencing high demand", "rate.?limit", "too many requests", "429", diff --git a/packages/ai/test/retry.test.ts b/packages/ai/test/retry.test.ts index 6d1a337d0..5fca45d63 100644 --- a/packages/ai/test/retry.test.ts +++ b/packages/ai/test/retry.test.ts @@ -12,6 +12,8 @@ const bunFetchSocketClosedMessage = const openAIResponsesEarlyEofMessage = "OpenAI Responses stream ended before a terminal response event"; const wrappedDnsLookupError = "The pending stream has been canceled (caused by: getaddrinfo ENOTFOUND bedrock-runtime.us-east-1.amazonaws.com)"; +const azurePeakLoadError = + "The system is currently experiencing high demand and cannot process your request. Your request exceeds the maximum usage size allowed during peak load. For improved capacity reliability, consider switching to Provisioned Throughput."; describe("provider retry classification", () => { it("matches explicit provider retry guidance", () => { @@ -68,6 +70,13 @@ describe("provider retry classification", () => { ).toBe(true); }); + it("matches Azure peak-load capacity errors", () => { + // Regression for #9669. + expect( + isRetryableAssistantError(fauxAssistantMessage("", { stopReason: "error", errorMessage: azurePeakLoadError })), + ).toBe(true); + }); + it("keeps provider limit errors non-retryable", () => { expect( isRetryableAssistantError(