From 815e7c4a3519e42ca25cab6fc12781bec9245c03 Mon Sep 17 00:00:00 2001 From: whning Date: Sat, 16 May 2026 12:55:00 +0800 Subject: [PATCH] Fix #13516 - Parse plugin name from fully qualified function name in MEAI conversion --- .../meai/Extensions/ChatMessageExtensions.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dotnet/src/InternalUtilities/meai/Extensions/ChatMessageExtensions.cs b/dotnet/src/InternalUtilities/meai/Extensions/ChatMessageExtensions.cs index b82bfb61f577..02b1fcde5f79 100644 --- a/dotnet/src/InternalUtilities/meai/Extensions/ChatMessageExtensions.cs +++ b/dotnet/src/InternalUtilities/meai/Extensions/ChatMessageExtensions.cs @@ -36,7 +36,8 @@ internal static ChatMessageContent ToChatMessageContent(this ChatMessage message Microsoft.Extensions.AI.DataContent dc => new Microsoft.SemanticKernel.BinaryContent(dc.Uri), Microsoft.Extensions.AI.UriContent uc => new Microsoft.SemanticKernel.BinaryContent(uc.Uri), Microsoft.Extensions.AI.FunctionCallContent fcc => new Microsoft.SemanticKernel.FunctionCallContent( - functionName: fcc.Name, + functionName: GetFunctionName(fcc.Name, out string? pluginName), + pluginName: pluginName, id: fcc.CallId, arguments: fcc.Arguments is not null ? new(fcc.Arguments) : null), Microsoft.Extensions.AI.FunctionResultContent frc => new Microsoft.SemanticKernel.FunctionResultContent( @@ -63,6 +64,19 @@ internal static ChatMessageContent ToChatMessageContent(this ChatMessage message .Select(m => m.Contents .FirstOrDefault(c => c is Microsoft.Extensions.AI.FunctionCallContent fcc && fcc.CallId == callId) as Microsoft.Extensions.AI.FunctionCallContent) .FirstOrDefault(fcc => fcc is not null); + + static string GetFunctionName(string name, out string? pluginName) + { + int underscoreIndex = name.IndexOf('_'); + if (underscoreIndex > 0) + { + pluginName = name.Substring(0, underscoreIndex); + return name.Substring(underscoreIndex + 1); + } + + pluginName = null; + return name; + } } /// Converts a list of to a .