@@ -872,20 +872,20 @@ describe("CodexSessionRuntime collab integration", () => {
872872describe ( "CodexSessionRuntime compaction" , ( ) => {
873873 it . effect ( "restores T3 context after the root thread compacts" , ( ) =>
874874 Effect . gen ( function * ( ) {
875+ const compacted = ( threadId : string ) => ( {
876+ method : "item/completed" ,
877+ params : {
878+ threadId,
879+ turnId : `${ threadId } -turn` ,
880+ completedAtMs : 0 ,
881+ item : { type : "contextCompaction" , id : `compaction-${ threadId } ` } ,
882+ } ,
883+ } ) ;
875884 const script = {
876885 rootThreadId : ROOT ,
877886 recordRequests : true ,
878- notifications : [
879- {
880- method : "item/completed" ,
881- params : {
882- threadId : ROOT ,
883- turnId : `${ ROOT } -turn` ,
884- completedAtMs : 0 ,
885- item : { type : "contextCompaction" , id : "compaction-1" } ,
886- } ,
887- } ,
888- ] ,
887+ // A child's compaction must not inject into the root thread.
888+ notifications : [ compacted ( CHILD_A ) , compacted ( ROOT ) ] ,
889889 } ;
890890 // @effect -diagnostics-next-line preferSchemaOverJson:off
891891 NodeFS . writeFileSync ( scriptPath , JSON . stringify ( script ) , "utf8" ) ;
@@ -919,7 +919,9 @@ describe("CodexSessionRuntime compaction", () => {
919919 yield * Fiber . join ( completedFiber ) ;
920920
921921 // The restore is awaited before later notifications, so it has landed.
922- const [ inject ] = readRecordedRequests ( ) ;
922+ const requests = readRecordedRequests ( ) ;
923+ assert . lengthOf ( requests , 1 ) ;
924+ const [ inject ] = requests ;
923925 assert . isDefined ( inject ) ;
924926 assert . equal ( inject . method , "thread/inject_items" ) ;
925927 assert . equal ( inject . params . threadId , ROOT ) ;
0 commit comments