Skip to content

.Net: Feature converts FunctionChoiceBehavior into ToolCallBehavior gemini mistral#13101

Closed
sadikulsayed wants to merge 2 commits into
microsoft:mainfrom
sadikulsayed:feature_FunctionChoiceBehavior_gemini_Mistral
Closed

.Net: Feature converts FunctionChoiceBehavior into ToolCallBehavior gemini mistral#13101
sadikulsayed wants to merge 2 commits into
microsoft:mainfrom
sadikulsayed:feature_FunctionChoiceBehavior_gemini_Mistral

Conversation

@sadikulsayed

@sadikulsayed sadikulsayed commented Sep 10, 2025

Copy link
Copy Markdown

Motivation and Context

Description

Contribution Checklist

@sadikulsayed sadikulsayed requested a review from a team as a code owner September 10, 2025 09:01
@moonbox3 moonbox3 added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel labels Sep 10, 2025
@github-actions github-actions Bot changed the title Feature function choice behavior gemini mistral .Net: Feature function choice behavior gemini mistral Sep 10, 2025
@sadikulsayed sadikulsayed changed the title .Net: Feature function choice behavior gemini mistral .Net: Feature converts FunctionChoiceBehavior into ToolCallBehavior gemini mistral Sep 10, 2025
Comment on lines +706 to +709
if (executionSettings.FunctionChoiceBehavior != null)
{
ConfigureMistralRequestTool(request, kernel);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider supporting other choices. Same for the other connector:

if (executionSettings.FunctionChoiceBehavior is { } functionChoiceBehavior)
{
    var config = functionChoiceBehavior.GetConfiguration(new FunctionChoiceBehaviorConfigurationContext(chatHistory) { Kernel = kernel });

    if (config.Choice == FunctionChoice.Auto)
    {
        executionSettings.ToolCallBehavior ??= MistralAIToolCallBehavior.AutoInvokeKernelFunctions;
    }
    else if (config.Choice == FunctionChoice.Required && config.Functions is { Count: > 0 } functions)
    {
        executionSettings.ToolCallBehavior ??= MistralAIToolCallBehavior.RequiredFunctions(functions, config.AutoInvoke);
    }
    else if (config.Choice == FunctionChoice.None)
    {
        executionSettings.ToolCallBehavior ??= MistralAIToolCallBehavior.NoKernelFunctions;
    }
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@SergeyMenshykh
This fix is for HandoffActor.cs not sending tool information to LLM as its setting FunctionChoiceBehavior.
AgentInvokeOptions options = new() { Kernel = kernel, KernelArguments = new(new PromptExecutionSettings { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() }), OnIntermediateMessage = messageHandler, };

this PR is just to send tools list to llm when FunctionChoiceBehavior is not null. When FunctionChoice.Auto / FunctionChoice.Required tools list we will be sending to LLM always.
Now this additional check where we will be needing can you please help me with some details.

https://learn.microsoft.com/en-us/semantic-kernel/support/migration/function-calling-migration-guide?pivots=programming-language-csharp

this says that we want to migrate from ToolCallBehavior to FunctionChoiceBehavior.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this says that we want to migrate from ToolCallBehavior to FunctionChoiceBehavior.

This is the ideal scenario instead of adapting the FunctionChoiceBehavior to a ToolCallBehavior, having old ToolCallBehavior implementations updated to the new FunctionChoiceBehavior architecture.

Currently we are appreciating any contributions on this path.

@westey-m

Copy link
Copy Markdown
Contributor

This PR looks stale. Closing for now, please reopen if still needed.

@westey-m westey-m closed this Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants