@@ -7,6 +7,7 @@ import {
|
7 | 7 | isOverloadedErrorMessage, |
8 | 8 | isRateLimitErrorMessage, |
9 | 9 | isServerErrorMessage, |
| 10 | +isTimeoutErrorMessage, |
10 | 11 | } from "./failover-matches.js"; |
11 | 12 | |
12 | 13 | describe("Z.ai vendor error codes (#48988)", () => { |
@@ -177,3 +178,35 @@ describe("server error status classification", () => {
|
177 | 178 | expect(isServerErrorMessage("Proxy notice: Status: Internal Server Error")).toBe(false); |
178 | 179 | }); |
179 | 180 | }); |
| 181 | + |
| 182 | +describe("generic assistant error text classification (#93931)", () => { |
| 183 | +it("classifies the generic 'LLM request failed.' as a timeout (transient)", () => { |
| 184 | +// The generic error text wraps provider availability failures (model not |
| 185 | +// loaded, endpoint unreachable) that should engage retry/fallback. |
| 186 | +expect(classifyFailoverReason("LLM request failed.")).toBe("timeout"); |
| 187 | +}); |
| 188 | + |
| 189 | +it("classifies lowercase 'llm request failed.' as a timeout", () => { |
| 190 | +expect(classifyFailoverReason("llm request failed.")).toBe("timeout"); |
| 191 | +}); |
| 192 | + |
| 193 | +it("does NOT match 'LLM request failed:' variants as timeout via this pattern", () => { |
| 194 | +// Variants with specific reasons should be classified by their own patterns, |
| 195 | +// not by the generic LLM request failed match. The schema rejection variant |
| 196 | +// is a format error, not a transient timeout. |
| 197 | +expect( |
| 198 | +isTimeoutErrorMessage( |
| 199 | +"LLM request failed: provider rejected the request schema or tool payload.", |
| 200 | +), |
| 201 | +).toBe(false); |
| 202 | +}); |
| 203 | + |
| 204 | +it("does NOT match 'LLM request failed: connection refused' as timeout via this exact-match pattern", () => { |
| 205 | +// The connection-refused variant is a sanitized user-facing string, not |
| 206 | +// the raw error that cron/failover classifiers see. The exact-match regex |
| 207 | +// /^llm request failed\.$/i should NOT match it because of the colon suffix. |
| 208 | +expect( |
| 209 | +isTimeoutErrorMessage("LLM request failed: connection refused by the provider endpoint."), |
| 210 | +).toBe(false); |
| 211 | +}); |
| 212 | +}); |