Skip to content

Conversation

@SergeyMenshykh
Copy link
Member

This PR fixes the issue when an MCP function is called with an argument that doesn't match the expected parameter type.

From chat:

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:
image

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where MCP function arguments with complex types (e.g., List<string>) were being incorrectly deserialized as strings instead of retaining their original type information in handoff orchestration scenarios.

Key Changes:

  • Enabled RetainArgumentTypes in FunctionChoiceBehavior options within HandoffActor.CreateInvokeOptions()
  • Ensures function arguments are deserialized as JsonElement objects to preserve type information
  • Aligns the handoff orchestration behavior with OpenAI Response agents and MCP samples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Nov 18, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 18, 2025
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Nov 18, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 18, 2025
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Nov 18, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 18, 2025
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Nov 18, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 19, 2025
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Nov 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 19, 2025
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Nov 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 19, 2025
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Nov 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 19, 2025
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Nov 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 19, 2025
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Nov 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 19, 2025
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Nov 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 19, 2025
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Nov 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 19, 2025
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Nov 19, 2025
@crickman crickman requested a review from roji November 19, 2025 21:20
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Nov 19, 2025
@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Nov 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 19, 2025
@crickman crickman added this pull request to the merge queue Nov 19, 2025
Merged via the queue into microsoft:main with commit 73337db Nov 19, 2025
21 of 24 checks passed
@github-project-automation github-project-automation bot moved this from Sprint: In Review to Sprint: Done in Semantic Kernel Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Sprint: Done

Development

Successfully merging this pull request may close these issues.

4 participants