@@ -345,6 +345,44 @@ void describe('Conversation turn response sender', () => {
345345 ) ;
346346 } ) ;
347347
348+ void it ( 'does not include metrics and usage for non-stop-reason chunks' , async ( ) => {
349+ const userAgentProvider = new UserAgentProvider (
350+ { } as unknown as ConversationTurnEvent ,
351+ ) ;
352+ mock . method ( userAgentProvider , 'getUserAgent' , ( ) => '' ) ;
353+ const graphqlRequestExecutor = new GraphqlRequestExecutor (
354+ '' ,
355+ '' ,
356+ userAgentProvider ,
357+ ) ;
358+ const executeGraphqlMock = mock . method (
359+ graphqlRequestExecutor ,
360+ 'executeGraphql' ,
361+ ( ) => Promise . resolve ( ) ,
362+ ) ;
363+ const sender = new ConversationTurnResponseSender (
364+ event ,
365+ userAgentProvider ,
366+ graphqlRequestExecutor ,
367+ ) ;
368+ const chunk : StreamingResponseChunk = {
369+ accumulatedTurnContent : [ { text : 'testContent' } ] ,
370+ associatedUserMessageId : 'testAssociatedUserMessageId' ,
371+ contentBlockIndex : 0 ,
372+ contentBlockDeltaIndex : 0 ,
373+ conversationId : 'testConversationId' ,
374+ contentBlockText : 'testBlockText' ,
375+ } ;
376+ await sender . sendResponseChunk ( chunk ) ;
377+
378+ assert . strictEqual ( executeGraphqlMock . mock . calls . length , 1 ) ;
379+ const request = executeGraphqlMock . mock . calls [ 0 ]
380+ . arguments [ 0 ] as GraphqlRequest < MutationStreamingResponseInput > ;
381+ const input = request . variables . input as Record < string , unknown > ;
382+ assert . strictEqual ( input . metrics , undefined ) ;
383+ assert . strictEqual ( input . usage , undefined ) ;
384+ } ) ;
385+
348386 void it ( 'sends errors response back to appsync' , async ( ) => {
349387 const userAgentProvider = new UserAgentProvider (
350388 { } as unknown as ConversationTurnEvent ,
0 commit comments