Skip to content

Commit 90b7037

Browse files
.Net: Enable argument types retention in handoff orchestration. (#13367)
This PR fixes the issue when an MCP function is called with an argument that doesn't match the expected parameter type. From chat: ```csharp public async Task<string> GetDataAsync( [Description("Optional modality type filter (CT, MRI, XA, etc.). Make sure it is a LIST of strings. Examples: ['CT'] or ['CT', 'MR']")] List<string>? modalityType = null, (...............) ``` When we tested it using Semantic Kernel without MCP, it returned the data in the correct format. However, when we integrated it into the tool (one API Server where we initialize the Kernel and another MCP Server with all the functions), we get the incorrect format: <img width="1186" height="175" alt="image" src="https://github.com/user-attachments/assets/9efd26e2-77fc-4ec2-85ed-60a35fa9e821" />
1 parent de20575 commit 90b7037

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

dotnet/src/Agents/Orchestration/Handoff/HandoffActor.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@ protected override AgentInvokeOptions CreateInvokeOptions(Func<ChatMessageConten
7171
new()
7272
{
7373
Kernel = kernel,
74-
KernelArguments = new(new PromptExecutionSettings { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() }),
74+
KernelArguments = new(new PromptExecutionSettings
75+
{
76+
FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(options: new()
77+
{
78+
RetainArgumentTypes = true,
79+
})
80+
}),
7581
OnIntermediateMessage = messageHandler,
7682
};
7783

dotnet/src/VectorData/SqliteVec/SqliteMapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public TRecord MapFromStorageToDataModel(DbDataReader reader, bool includeVector
5656
}
5757

5858
var floats = new float[length / 4];
59-
var bytes = MemoryMarshal.Cast<float, byte>(floats);
59+
var bytes = MemoryMarshal.Cast<float, byte>(floats.AsSpan());
6060
stream.ReadExactly(bytes);
6161
#else
6262
var floats = MemoryMarshal.Cast<byte, float>((byte[])reader[ordinal]).ToArray();

0 commit comments

Comments
 (0)