@@ -2849,6 +2849,81 @@ it.effect("SQL projection keeps background thread updates out of updatedAt", ()
28492849 backgroundThreadUpdatesKeepTimestamp . pipe ( Effect . provide ( layerTest ) ) ,
28502850) ;
28512851
2852+ it . effect ( "awareness snapshots leave a linked environment's finished task to its parent" , ( ) =>
2853+ Effect . gen ( function * ( ) {
2854+ const store = yield * ProjectionStore . ProjectionStoreV2 ;
2855+ const now = yield * DateTime . now ;
2856+ const threadId = ThreadId . make ( "thread:delegated-awareness" ) ;
2857+ const runId = RunId . make ( "run:delegated-awareness" ) ;
2858+ yield * store . apply ( {
2859+ id : EventId . make ( "event:delegated-awareness:created" ) ,
2860+ type : "thread.created" ,
2861+ threadId,
2862+ occurredAt : now ,
2863+ payload : {
2864+ createdBy : "agent" ,
2865+ creationSource : "server" ,
2866+ id : threadId ,
2867+ projectId : ProjectId . make ( "project:delegated-awareness" ) ,
2868+ title : "Delegated task" ,
2869+ providerInstanceId,
2870+ modelSelection,
2871+ runtimeMode : "full-access" ,
2872+ interactionMode : "default" ,
2873+ branch : null ,
2874+ worktreePath : null ,
2875+ activeProviderThreadId : null ,
2876+ lineage : { parentThreadId : null , relationshipToParent : null , rootThreadId : threadId } ,
2877+ delegatedFrom : {
2878+ environmentId : EnvironmentId . make ( "environment:parent" ) ,
2879+ threadId : ThreadId . make ( "thread:parent-elsewhere" ) ,
2880+ title : "Parent" ,
2881+ } ,
2882+ forkedFrom : null ,
2883+ createdAt : now ,
2884+ updatedAt : now ,
2885+ archivedAt : null ,
2886+ settledOverride : null ,
2887+ settledAt : null ,
2888+ lastVisitedAt : null ,
2889+ deletedAt : null ,
2890+ } ,
2891+ } ) ;
2892+ yield * store . apply ( {
2893+ id : EventId . make ( "event:delegated-awareness:run" ) ,
2894+ type : "run.created" ,
2895+ threadId,
2896+ occurredAt : now ,
2897+ payload : {
2898+ id : runId ,
2899+ threadId,
2900+ ordinal : 1 ,
2901+ providerInstanceId,
2902+ modelSelection,
2903+ providerThreadId : null ,
2904+ userMessageId : MessageId . make ( "message:delegated-awareness" ) ,
2905+ rootNodeId : NodeId . make ( "node:delegated-awareness" ) ,
2906+ activeAttemptId : null ,
2907+ status : "completed" ,
2908+ requestedAt : now ,
2909+ startedAt : now ,
2910+ completedAt : now ,
2911+ checkpointId : null ,
2912+ contextHandoffId : null ,
2913+ } ,
2914+ } ) ;
2915+ const [ thread ] = ( yield * store . getAgentAwarenessSnapshot ( threadId ) ) . threads ;
2916+ assert . equal ( thread ?. status , "completed" ) ;
2917+ assert . isNull (
2918+ projectThreadAwarenessV2 ( {
2919+ environmentId : EnvironmentId . make ( "test" ) ,
2920+ project : { title : "Test" } ,
2921+ thread : thread ! ,
2922+ } ) ,
2923+ ) ;
2924+ } ) . pipe ( Effect . provide ( layerTest ) ) ,
2925+ ) ;
2926+
28522927const runlessNativeSubagentNeedsRecovery = Effect . gen ( function * ( ) {
28532928 const store = yield * ProjectionStore . ProjectionStoreV2 ;
28542929 const threadId = yield * addRolledBackRecoveryCandidate ( "runless-native-recovery" ) ;
0 commit comments