@@ -5102,31 +5102,57 @@ describe("main-session-restart-recovery", () => {
51025102 } ) ;
51035103 } ) ;
51045104
5105- it ( "keeps an unmatched failed wait restricted when its checkpoint is replay-safe" , async ( ) => {
5106- await writeMainSessionTranscript ( [
5107- { role : "user" , content : "do the thing" } ,
5108- codeModeCheckpointMessage ( ) ,
5109- codeModeWaitCallMessage ( ) ,
5110- {
5111- role : "toolResult" ,
5112- toolName : "wait" ,
5113- toolCallId : "call-other" ,
5114- content : [ { type : "text" , text : "Error: The operation was aborted." } ] ,
5115- details : {
5116- status : "failed" ,
5117- error : "Error: The operation was aborted." ,
5118- code : "internal_error" ,
5119- } ,
5120- isError : true ,
5121- } ,
5122- ] ) ;
5105+ it . each ( [
5106+ {
5107+ label : "matching failed-wait result identity" ,
5108+ toolCallIds : [ "call-wait-1" ] ,
5109+ restoresCodeModeTools : true ,
5110+ } ,
5111+ {
5112+ label : "mismatched failed-wait result identity" ,
5113+ toolCallIds : [ "call-other" ] ,
5114+ restoresCodeModeTools : false ,
5115+ } ,
5116+ {
5117+ label : "missing failed-wait result identity" ,
5118+ toolCallIds : [ undefined ] ,
5119+ restoresCodeModeTools : false ,
5120+ } ,
5121+ {
5122+ label : "duplicate failed-wait result identities" ,
5123+ toolCallIds : [ "call-wait-1" , "call-wait-1" ] ,
5124+ restoresCodeModeTools : false ,
5125+ } ,
5126+ ] ) (
5127+ "restores Code Mode tools only for exactly one $label" ,
5128+ async ( { toolCallIds, restoresCodeModeTools } ) => {
5129+ await writeMainSessionTranscript ( [
5130+ { role : "user" , content : "do the thing" } ,
5131+ codeModeCheckpointMessage ( ) ,
5132+ codeModeWaitCallMessage ( ) ,
5133+ ...toolCallIds . map ( ( toolCallId ) => ( {
5134+ role : "toolResult" ,
5135+ toolName : "wait" ,
5136+ ...( toolCallId ? { toolCallId } : { } ) ,
5137+ content : [ { type : "text" , text : "Error: The operation was aborted." } ] ,
5138+ details : {
5139+ status : "failed" ,
5140+ error : "Error: The operation was aborted." ,
5141+ code : "internal_error" ,
5142+ } ,
5143+ isError : true ,
5144+ } ) ) ,
5145+ ] ) ;
51235146
5124- await expectRecovery ( { recovered : 1 , failed : 0 , skipped : 0 } ) ;
5125- expect ( gatewayParams ( ) ) . toMatchObject ( {
5126- forceRestartSafeTools : true ,
5127- forceCodeModeTools : true ,
5128- } ) ;
5129- } ) ;
5147+ await expectRecovery ( { recovered : 1 , failed : 0 , skipped : 0 } ) ;
5148+ expect ( gatewayParams ( ) ) . toMatchObject ( { forceRestartSafeTools : true } ) ;
5149+ if ( restoresCodeModeTools ) {
5150+ expect ( gatewayParams ( ) ) . toMatchObject ( { forceCodeModeTools : true } ) ;
5151+ } else {
5152+ expect ( gatewayParams ( ) ) . not . toHaveProperty ( "forceCodeModeTools" ) ;
5153+ }
5154+ } ,
5155+ ) ;
51305156
51315157 it . each ( [
51325158 {
0 commit comments