@@ -1043,6 +1043,69 @@ describe('createStreamingResponse agent-events-v1', () => {
10431043 expect ( events . some ( ( event ) => event . event === 'final' ) ) . toBe ( true )
10441044 } )
10451045
1046+ it ( 'suppresses final selected output when streamed content is keyed by invocation' , async ( ) => {
1047+ const stream = await createStreamingResponse ( {
1048+ requestId : 'request-invocation-selected-output' ,
1049+ streamConfig : {
1050+ selectedOutputs : [ 'agent-1_content' ] ,
1051+ } ,
1052+ executeFn : async ( { onStream, onBlockComplete } ) => {
1053+ await onStream ( {
1054+ stream : new ReadableStream < Uint8Array > ( {
1055+ start ( controller ) {
1056+ controller . enqueue ( new TextEncoder ( ) . encode ( 'current answer' ) )
1057+ controller . close ( )
1058+ } ,
1059+ } ) ,
1060+ streamFormat : 'text' ,
1061+ blockExecutionId : 'invoke-current' ,
1062+ execution : {
1063+ blockId : 'agent-1' ,
1064+ success : true ,
1065+ output : { content : 'current answer' } ,
1066+ logs : [ ] ,
1067+ metadata : { } ,
1068+ } ,
1069+ } as any )
1070+ await onBlockComplete ( 'agent-1' , { content : 'current answer' } , 'invoke-current' )
1071+
1072+ return {
1073+ success : true ,
1074+ output : { content : 'current answer' } ,
1075+ logs : [
1076+ {
1077+ blockId : 'agent-1' ,
1078+ blockExecutionId : 'invoke-stale' ,
1079+ output : { content : 'stale answer' } ,
1080+ startedAt : new Date ( ) . toISOString ( ) ,
1081+ endedAt : new Date ( ) . toISOString ( ) ,
1082+ durationMs : 1 ,
1083+ success : true ,
1084+ } ,
1085+ {
1086+ blockId : 'agent-1' ,
1087+ blockExecutionId : 'invoke-current' ,
1088+ output : { content : '' } ,
1089+ startedAt : new Date ( ) . toISOString ( ) ,
1090+ endedAt : new Date ( ) . toISOString ( ) ,
1091+ durationMs : 1 ,
1092+ success : true ,
1093+ } ,
1094+ ] ,
1095+ } as any
1096+ } ,
1097+ } )
1098+
1099+ const events = await collectSSEEvents ( stream )
1100+ expect ( events . filter ( ( event ) => event . chunk !== undefined ) ) . toEqual ( [
1101+ { blockId : 'agent-1' , chunk : 'current answer' } ,
1102+ ] )
1103+ expect ( events . find ( ( event ) => event . event === 'final' ) ) . toEqual ( {
1104+ event : 'final' ,
1105+ data : { success : true , output : { } } ,
1106+ } )
1107+ } )
1108+
10461109 it ( 'stays fully text-only when both policies are off' , async ( ) => {
10471110 const stream = await createStreamingResponse ( {
10481111 requestId : 'request-1' ,
0 commit comments