Skip to content

.Net: * Bug: After using the AddFromFunctions function to add a plugin, the parameter number type cannot be passed when the plugin is automatically called for transmission in GetStreamingChatmessageContentsAsync. #12118

Closed
@xiaoshuoq923

Description

@xiaoshuoq923

Describe the bug
After using the AddFromFunctions function to add a plugin, the parameter number type cannot be passed when the plugin is automatically called for transmission in GetStreamingChatmessageContentsAsync.

To Reproduce
Code:
var SseConfig = new SseClientTransportOptions
{
Endpoint = new Uri("https://xxxx/sse"),
Name = McpserverName,
};
client = await McpClientFactory.CreateAsync(
new SseClientTransport(SseConfig),
defaultOptions);
var tools = await client.ListToolsAsync();

#pragma warning disable SKEXP0001
kernel.Plugins.AddFromFunctions(McpserverName, tools.Select(aiFunction => aiFunction.AsKernelFunction()));
#pragma warning restore SKEXP0001

OpenAIPromptExecutionSettings openAIPromptExecutionSettings = new()
{
ToolCallBehavior = ToolCallBehavior.AutoInvokeKernelFunctions,
};

await foreach (var message in chatCompletionService?.GetStreamingChatMessageContentsAsync(history,
               openAIPromptExecutionSettings, kernel))

{

}

Expected behavior
Parameters displayed in history:
{"query":"weather forecast","num_results":5}

Plugin error message:
{"content":[{"type":"text","text":"MCP error -32602: Invalid arguments for tool bing_search: [\n {\n "code": "invalid_type",\n "expected": "number",\n "received": "string",\n "path": [\n "num_results"\n ],\n "message": "Expected number, received string"\n }\n]"}],"isError":true}

Platform
Language: C#
Source: Microsoft.SemanticKernel 1.49.0
AI model: DeepSeek-V3
IDE: Visual Studio
OS: Windows

Metadata

Metadata

Labels

.NETIssue or Pull requests regarding .NET codebugSomething isn't working

Type

Projects

Status

Sprint: In Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions