From c96b9a3a0776b7bcb089324dee032c095ebbc01f Mon Sep 17 00:00:00 2001 From: junyuc25 Date: Sat, 14 Mar 2026 00:06:24 -0700 Subject: [PATCH] fix(failover): widen raw 402 detection for third-party proxy messages --- .../pi-embedded-helpers.isbillingerrormessage.test.ts | 6 ++++++ src/agents/pi-embedded-helpers/failover-matches.ts | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts b/src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts index fc1ec760752..b2347e8d98d 100644 --- a/src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts +++ b/src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts @@ -1014,6 +1014,12 @@ describe("classifyFailoverReason", () => { "402 You've used up your points! Visit https://poe.com/api/keys to get more.", ), ).toBe("billing"); + // Third-party proxy 402 with non-standard wording (#45774) + expect( + classifyFailoverReason( + "402 No available asset for API access, please purchase a subscription", + ), + ).toBe("billing"); expect(classifyFailoverReason(INSUFFICIENT_QUOTA_PAYLOAD)).toBe("billing"); expect(classifyFailoverReason("deadline exceeded")).toBe("timeout"); expect(classifyFailoverReason("request ended without sending any chunks")).toBe("timeout"); diff --git a/src/agents/pi-embedded-helpers/failover-matches.ts b/src/agents/pi-embedded-helpers/failover-matches.ts index 14d7ede0b1c..efa5ff62166 100644 --- a/src/agents/pi-embedded-helpers/failover-matches.ts +++ b/src/agents/pi-embedded-helpers/failover-matches.ts @@ -217,6 +217,8 @@ export function isBillingErrorMessage(raw: string): boolean { value.includes("upgrade") || value.includes("credits") || value.includes("payment") || + value.includes("purchase") || + value.includes("subscription") || value.includes("plan") ); }