@@ -58,6 +58,11 @@ type ProcessOutputStreamOptions<OUTPUT = undefined> = {
5858 transportResolver ?: ( ) => StreamTransport | undefined ;
5959} ;
6060
61+ function buildResponseModelMetadata ( runState : AgenticRunState ) : { metadata : Record < string , unknown > } | undefined {
62+ const modelId = runState . state . responseMetadata ?. modelId ;
63+ return modelId ? { metadata : { modelId } } : undefined ;
64+ }
65+
6166async function processOutputStream < OUTPUT = undefined > ( {
6267 tools,
6368 messageId,
@@ -131,6 +136,7 @@ async function processOutputStream<OUTPUT = undefined>({
131136 ...( providerMetadata ? { providerMetadata } : { } ) ,
132137 } ,
133138 ] ,
139+ ...buildResponseModelMetadata ( runState ) ,
134140 } ,
135141 createdAt : new Date ( ) ,
136142 } ;
@@ -274,6 +280,7 @@ async function processOutputStream<OUTPUT = undefined>({
274280 providerMetadata : chunk . payload . providerMetadata ?? runState . state . providerOptions ,
275281 } ,
276282 ] ,
283+ ...buildResponseModelMetadata ( runState ) ,
277284 } ,
278285 createdAt : new Date ( ) ,
279286 } ;
@@ -313,6 +320,7 @@ async function processOutputStream<OUTPUT = undefined>({
313320 providerMetadata : chunk . payload . providerMetadata ?? runState . state . providerOptions ,
314321 } ,
315322 ] ,
323+ ...buildResponseModelMetadata ( runState ) ,
316324 } ,
317325 createdAt : new Date ( ) ,
318326 } ;
@@ -346,6 +354,7 @@ async function processOutputStream<OUTPUT = undefined>({
346354 mimeType : chunk . payload . mimeType ,
347355 } ,
348356 ] ,
357+ ...buildResponseModelMetadata ( runState ) ,
349358 } ,
350359 createdAt : new Date ( ) ,
351360 } ;
@@ -373,6 +382,7 @@ async function processOutputStream<OUTPUT = undefined>({
373382 } ,
374383 } ,
375384 ] ,
385+ ...buildResponseModelMetadata ( runState ) ,
376386 } ,
377387 createdAt : new Date ( ) ,
378388 } ;
@@ -1075,6 +1085,7 @@ export function createLLMExecutionStep<TOOLS extends ToolSet = ToolSet, OUTPUT =
10751085 providerExecuted : toolCall . providerExecuted ,
10761086 } ;
10771087 } ) ,
1088+ ...buildResponseModelMetadata ( runState ) ,
10781089 } ,
10791090 createdAt : new Date ( ) ,
10801091 } ;
0 commit comments