@@ -4,6 +4,11 @@ import { GENERIC_EXTERNAL_RUN_FAILURE_TEXT } from "../failover/user-copy.js";
44import { runWithModelFallback } from "../model-fallback-runner.js" ;
55import { classifyEmbeddedAgentRunResultForModelFallback } from "./result-fallback-classifier.js" ;
66
7+ const supplementalSpeechPayload = {
8+ mediaUrl : "file:///tmp/answer.mp3" ,
9+ ttsSupplement : { spokenText : "answer" , visibleTextAlreadyDelivered : true } ,
10+ } ;
11+
712describe ( "classifyEmbeddedAgentRunResultForModelFallback" , ( ) => {
813 it ( "does not fallback when sessions_spawn accepted a child session" , ( ) => {
914 // Accepted child sessions mean the turn made progress even if the parent did
@@ -128,7 +133,23 @@ describe("classifyEmbeddedAgentRunResultForModelFallback", () => {
128133 } ) ;
129134 } ) ;
130135
131- it ( "advances to the configured fallback after a generic external runner failure" , async ( ) => {
136+ it . each ( [
137+ {
138+ name : "a generic external runner failure" ,
139+ payload : { text : GENERIC_EXTERNAL_RUN_FAILURE_TEXT } ,
140+ code : "generic_external_run_failure" ,
141+ } ,
142+ {
143+ name : "a transient status notice without a final reply" ,
144+ payload : { text : "Still working" , isStatusNotice : true } ,
145+ code : "empty_result" ,
146+ } ,
147+ {
148+ name : "supplemental speech without a final reply" ,
149+ payload : supplementalSpeechPayload ,
150+ code : "empty_result" ,
151+ } ,
152+ ] ) ( "advances to the configured fallback after $name" , async ( { payload, code } ) => {
132153 const runs : Array < { provider : string ; model : string } > = [ ] ;
133154 const result = await runWithModelFallback ( {
134155 cfg : undefined ,
@@ -140,7 +161,7 @@ describe("classifyEmbeddedAgentRunResultForModelFallback", () => {
140161 runs . push ( { provider, model } ) ;
141162 return runs . length === 1
142163 ? {
143- payloads : [ { text : GENERIC_EXTERNAL_RUN_FAILURE_TEXT } ] ,
164+ payloads : [ payload ] ,
144165 meta : { durationMs : 1 } ,
145166 }
146167 : { payloads : [ { text : "fallback ok" } ] , meta : { durationMs : 1 } } ;
@@ -162,9 +183,11 @@ describe("classifyEmbeddedAgentRunResultForModelFallback", () => {
162183 provider : "external" ,
163184 model : "primary" ,
164185 reason : "format" ,
165- code : "generic_external_run_failure" ,
166- error : GENERIC_EXTERNAL_RUN_FAILURE_TEXT ,
186+ code,
167187 } ) ;
188+ if ( code === "generic_external_run_failure" ) {
189+ expect ( result . attempts [ 0 ] ?. error ) . toBe ( GENERIC_EXTERNAL_RUN_FAILURE_TEXT ) ;
190+ }
168191 } ) ;
169192
170193 it ( "classifies Codex subscription usage-limit payloads as rate-limit fallback" , ( ) => {
@@ -446,6 +469,30 @@ describe("classifyEmbeddedAgentRunResultForModelFallback", () => {
446469 code : "empty_result" ,
447470 suffix : "without a visible assistant reply" ,
448471 } ,
472+ {
473+ name : "compaction-notice-only" ,
474+ payloads : [ { isCompactionNotice : true , text : "Compacting context" } ] ,
475+ code : "empty_result" ,
476+ suffix : "without a visible assistant reply" ,
477+ } ,
478+ {
479+ name : "fallback-notice-only" ,
480+ payloads : [ { isFallbackNotice : true , text : "Switching providers" } ] ,
481+ code : "empty_result" ,
482+ suffix : "without a visible assistant reply" ,
483+ } ,
484+ {
485+ name : "status-notice-only" ,
486+ payloads : [ { isStatusNotice : true , text : "Still working" } ] ,
487+ code : "empty_result" ,
488+ suffix : "without a visible assistant reply" ,
489+ } ,
490+ {
491+ name : "supplemental-speech-only" ,
492+ payloads : [ supplementalSpeechPayload ] ,
493+ code : "empty_result" ,
494+ suffix : "without a visible assistant reply" ,
495+ } ,
449496 {
450497 name : "explicitly hidden" ,
451498 payloads : [ { visible : false , text : "internal" } ] ,
0 commit comments