33 * Exercises raw error coercion, remediation hints, timeout/auth/billing/rate-limit cases.
44 */
55import { describe , expect , it } from "vitest" ;
6- import { classifyFailoverSignal } from "./embedded-agent-helpers/errors.js" ;
6+ import {
7+ classifyAssistantFailoverReason ,
8+ classifyFailoverSignal ,
9+ isFailoverAssistantError ,
10+ } from "./embedded-agent-helpers/errors.js" ;
711import {
812 buildFailoverRemediationHint ,
913 buildProviderReauthCommand ,
@@ -17,6 +21,7 @@ import {
1721 resolveFailoverStatus ,
1822} from "./failover-error.js" ;
1923import { SessionWriteLockTimeoutError } from "./session-write-lock-error.js" ;
24+ import { makeAssistantMessageFixture } from "./test-helpers/assistant-message-fixtures.js" ;
2025
2126// OpenAI 429 example shape: https://help.openai.com/en/articles/5955604-how-can-i-solve-429-too-many-requests-errors
2227const OPENAI_RATE_LIMIT_MESSAGE =
@@ -1466,4 +1471,21 @@ describe("upstream_error type triggers fallback", () => {
14661471 } ) ,
14671472 ) . toEqual ( { kind : "reason" , reason : "timeout" } ) ;
14681473 } ) ;
1474+
1475+ it ( "treats an upstream_error assistant message as fallbackable at the production gate" , ( ) => {
1476+ // The #95519 runtime path: the provider error surfaces as an assistant message with
1477+ // stopReason "error" and errorType "upstream_error" (no leading HTTP status, so HTTP-status
1478+ // classification does not apply). run.ts assistant-stage failover calls these exact
1479+ // functions (isFailoverAssistantError / classifyAssistantFailoverReason); before this fix
1480+ // both reported "not a failover error", so the run returned an error payload instead of
1481+ // throwing a FailoverError into the configured fallback chain.
1482+ const assistant = makeAssistantMessageFixture ( {
1483+ stopReason : "error" ,
1484+ provider : "demo-provider" ,
1485+ errorType : "upstream_error" ,
1486+ errorMessage : "Upstream request failed" ,
1487+ } ) ;
1488+ expect ( classifyAssistantFailoverReason ( assistant ) ) . toBe ( "timeout" ) ;
1489+ expect ( isFailoverAssistantError ( assistant ) ) . toBe ( true ) ;
1490+ } ) ;
14691491} ) ;
0 commit comments