@@ -575,6 +575,129 @@ describe("qa suite runtime agent session helpers", () => {
575575 } ) ;
576576 } ) ;
577577
578+ it ( "matches pending Code Mode waits to the exec checkpoint that created their run" , async ( ) => {
579+ const tempRoot = await makeTempDir ( "qa-session-transcript-code-mode-wait-" ) ;
580+ const sessionKey = "agent:qa:code-mode-wait" ;
581+ const sessionId = "session-code-mode-wait" ;
582+ await seedQaSession ( { tempRoot, sessionKey, sessionId } ) ;
583+
584+ for ( const message of [
585+ {
586+ role : "assistant" ,
587+ content : [
588+ {
589+ type : "toolCall" ,
590+ id : "checkpoint-1-exec" ,
591+ name : "exec" ,
592+ arguments : { code : "await qa_restart_wait(); return 'CHECKPOINT-1';" } ,
593+ } ,
594+ ] ,
595+ } ,
596+ {
597+ role : "toolResult" ,
598+ toolCallId : "checkpoint-1-exec" ,
599+ toolName : "exec" ,
600+ details : { status : "waiting" , runId : "checkpoint-1-run" } ,
601+ isError : false ,
602+ } ,
603+ {
604+ role : "assistant" ,
605+ content : [
606+ {
607+ type : "toolCall" ,
608+ id : "checkpoint-1-wait" ,
609+ name : "wait" ,
610+ arguments : { runId : "checkpoint-1-run" } ,
611+ } ,
612+ ] ,
613+ } ,
614+ {
615+ role : "toolResult" ,
616+ toolCallId : "checkpoint-1-wait" ,
617+ toolName : "wait" ,
618+ details : { status : "completed" } ,
619+ isError : false ,
620+ } ,
621+ {
622+ role : "assistant" ,
623+ content : [
624+ {
625+ type : "toolCall" ,
626+ id : "audit-exec" ,
627+ name : "exec" ,
628+ arguments : { code : "return await catalog.search('qa_restart_unsafe_probe');" } ,
629+ } ,
630+ ] ,
631+ } ,
632+ {
633+ role : "toolResult" ,
634+ toolCallId : "audit-exec" ,
635+ toolName : "exec" ,
636+ details : { status : "waiting" , runId : "audit-run" } ,
637+ isError : false ,
638+ } ,
639+ {
640+ role : "assistant" ,
641+ content : [
642+ {
643+ type : "toolCall" ,
644+ id : "audit-wait" ,
645+ name : "wait" ,
646+ arguments : { runId : "audit-run" } ,
647+ } ,
648+ ] ,
649+ } ,
650+ ] ) {
651+ await appendQaTranscriptMessage ( { tempRoot, sessionKey, sessionId, message } ) ;
652+ }
653+
654+ await expect (
655+ readSessionTranscriptSummary ( { gateway : { tempRoot } } as never , sessionKey , {
656+ pendingCodeModeExecNeedle : "CHECKPOINT-1" ,
657+ } ) ,
658+ ) . resolves . toMatchObject ( { hasPendingCodeModeWait : false } ) ;
659+
660+ for ( const message of [
661+ {
662+ role : "assistant" ,
663+ content : [
664+ {
665+ type : "toolCall" ,
666+ id : "checkpoint-2-exec" ,
667+ name : "exec" ,
668+ arguments : { code : "await qa_restart_wait(); return 'CHECKPOINT-2';" } ,
669+ } ,
670+ ] ,
671+ } ,
672+ {
673+ role : "toolResult" ,
674+ toolCallId : "checkpoint-2-exec" ,
675+ toolName : "exec" ,
676+ details : { status : "waiting" , runId : "checkpoint-2-run" } ,
677+ isError : false ,
678+ } ,
679+ {
680+ role : "assistant" ,
681+ content : [
682+ {
683+ type : "toolCall" ,
684+ id : "checkpoint-2-wait" ,
685+ name : "wait" ,
686+ arguments : { runId : "checkpoint-2-run" } ,
687+ } ,
688+ ] ,
689+ } ,
690+ ] ) {
691+ await appendQaTranscriptMessage ( { tempRoot, sessionKey, sessionId, message } ) ;
692+ }
693+
694+ await expect (
695+ readSessionTranscriptSummary ( { gateway : { tempRoot } } as never , sessionKey , {
696+ pendingCodeModeExecNeedle : "CHECKPOINT-2" ,
697+ } ) ,
698+ ) . resolves . toMatchObject ( { hasPendingCodeModeWait : true } ) ;
699+ } ) ;
700+
578701 it ( "only exposes authenticated successful tool results with finite owner timestamps" , async ( ) => {
579702 const tempRoot = await makeTempDir ( "qa-session-transcript-tool-event-timestamps-" ) ;
580703 const sessionKey = "agent:qa:tool-event-timestamps" ;
0 commit comments