@@ -206,15 +206,17 @@ export function createThinkingContent(
206206 * 创建 toolcall 类型的 AIMessageContent
207207 * @param toolCall 工具调用数据
208208 * @param status 状态
209- * @param strategy 策略
209+ * @param strategy 策略(可选,会根据 toolCallName 自动判断)
210210 * @returns toolcall 类型的 AIMessageContent
211211 */
212212export function createToolCallContent (
213213 toolCall : any ,
214214 status : 'pending' | 'streaming' | 'complete' = 'pending' ,
215215 strategy : 'append' | 'merge' = 'append' ,
216216) : any {
217- return createAIMessageContent ( 'toolcall' , toolCall , status , strategy ) ;
217+ // 根据 toolCallName 生成唯一的 type
218+ const type = `toolcall-${ toolCall . toolCallName } ` ;
219+ return createAIMessageContent ( type , toolCall , status , strategy ) ;
218220}
219221
220222/**
@@ -393,14 +395,15 @@ export function convertReasoningMessages(reasoningMessages: any[]): any[] {
393395 if ( msg . toolCalls && msg . toolCalls . length > 0 ) {
394396 msg . toolCalls . forEach ( ( toolCall : any ) => {
395397 const toolResult = toolCallMap . get ( toolCall . id ) ?. result || '' ;
398+ const toolCallData = {
399+ toolCallId : toolCall . id ,
400+ toolCallName : toolCall . function . name ,
401+ args : toolCall . function . arguments ,
402+ result : toolResult ,
403+ } ;
396404 reasoningData . push ( {
397- type : 'toolcall' ,
398- data : {
399- toolCallId : toolCall . id ,
400- toolCallName : toolCall . function . name ,
401- args : toolCall . function . arguments ,
402- result : toolResult ,
403- } ,
405+ type : `toolcall-${ toolCall . function . name } ` ,
406+ data : toolCallData ,
404407 status : 'complete' ,
405408 } ) ;
406409 } ) ;
@@ -456,14 +459,16 @@ export function processToolCalls(toolCalls: any[], toolCallMap: Map<string, any>
456459 } ;
457460 }
458461
462+ const toolCallData = {
463+ toolCallId : toolCall . id ,
464+ toolCallName : toolCall . function . name ,
465+ args : toolCall . function . arguments ,
466+ result : toolResult ,
467+ } ;
468+
459469 return {
460- type : 'toolcall' as const ,
461- data : {
462- toolCallId : toolCall . id ,
463- toolCallName : toolCall . function . name ,
464- args : toolCall . function . arguments ,
465- result : toolResult ,
466- } ,
470+ type : `toolcall-${ toolCall . function . name } ` as const ,
471+ data : toolCallData ,
467472 } ;
468473 } ) ;
469474}
0 commit comments