@@ -5804,6 +5804,87 @@ describe("CodexAdapterV2 post-settle continuation", () => {
58045804 ) ,
58055805 ) ;
58065806
5807+ const childTurnStartedIndex = interruptSubagentCommandTranscript . entries . findIndex (
5808+ ( entry ) => entry . type === "emit_inbound" && entry . label === "turn/started/child" ,
5809+ ) ;
5810+ const failedRootLiveChildTranscript = makeCodexReplayTranscript ( {
5811+ scenario : "codex-failed-root-live-subagent" ,
5812+ entries : [
5813+ ...interruptSubagentCommandTranscript . entries . slice ( 0 , childTurnStartedIndex + 1 ) ,
5814+ {
5815+ type : "emit_inbound" ,
5816+ label : "turn/completed/root-failed" ,
5817+ frame : {
5818+ method : "turn/completed" ,
5819+ params : {
5820+ threadId : INTERRUPT_NATIVE_THREAD ,
5821+ turn : {
5822+ ...makeCodexReplayTurn ( { id : INTERRUPT_NATIVE_TURN , status : "failed" } ) ,
5823+ error : {
5824+ message : "unsupported websocket request type: response.interrupt" ,
5825+ codexErrorInfo : "other" ,
5826+ additionalDetails : null ,
5827+ } ,
5828+ } ,
5829+ } ,
5830+ } ,
5831+ } ,
5832+ {
5833+ type : "emit_inbound" ,
5834+ label : "turn/completed/child" ,
5835+ afterMs : 30_000 ,
5836+ frame : {
5837+ method : "turn/completed" ,
5838+ params : {
5839+ threadId : INTERRUPT_CHILD_NATIVE_THREAD ,
5840+ turn : makeCodexReplayTurn ( { id : INTERRUPT_CHILD_NATIVE_TURN , status : "completed" } ) ,
5841+ } ,
5842+ } ,
5843+ } ,
5844+ { type : "runtime_exit" , status : "success" } ,
5845+ ] ,
5846+ } ) ;
5847+
5848+ it . effect ( "settles a failed root without waiting for subagents that keep running" , ( ) =>
5849+ Effect . scoped (
5850+ Effect . gen ( function * ( ) {
5851+ const harness = yield * makeCodexReplayHarness ( failedRootLiveChildTranscript ) ;
5852+ const now = yield * DateTime . now ;
5853+ const childTurnCompleted = ( ) =>
5854+ harness . events . some (
5855+ ( event ) =>
5856+ event . type === "provider_turn.updated" &&
5857+ event . threadId !== harness . threadId &&
5858+ event . providerTurn . status === "completed" ,
5859+ ) ;
5860+
5861+ yield * harness . runtime . startTurn (
5862+ makeCodexTestTurnInput ( {
5863+ threadId : harness . threadId ,
5864+ providerThread : harness . providerThread ,
5865+ now,
5866+ attemptId : RunAttemptId . make ( "attempt-codex-failed-root-live-subagent" ) ,
5867+ text : INTERRUPT_PROMPT ,
5868+ } ) ,
5869+ ) ;
5870+ yield * awaitUntil ( ( ) => harness . terminalEvents ( ) . length === 1 , "failed root terminal" ) ;
5871+
5872+ const terminal = harness . terminalEvents ( ) [ 0 ] ;
5873+ assert . equal ( terminal ?. status , "failed" ) ;
5874+ assert . isTrue ( terminal ?. status === "failed" && terminal . childTurnsContinue === true ) ;
5875+ assert . isFalse ( childTurnCompleted ( ) , "the subagent is still running" ) ;
5876+
5877+ yield * TestClock . adjust ( "30 seconds" ) ;
5878+ yield * awaitUntil ( childTurnCompleted , "subagent turn completion" ) ;
5879+ assert . lengthOf ( harness . terminalEvents ( ) , 1 ) ;
5880+ } ) . pipe (
5881+ Effect . provide (
5882+ Layer . mergeAll ( IdAllocator . layer , McpProviderSessions . layer , NodeServices . layer ) ,
5883+ ) ,
5884+ ) ,
5885+ ) ,
5886+ ) ;
5887+
58075888 const childTerminationResponseIndex = interruptSubagentCommandTranscript . entries . findIndex (
58085889 ( entry ) =>
58095890 entry . type === "emit_inbound" && entry . label === "thread/backgroundTerminals/terminate/child" ,
0 commit comments