Skip to content

.Net: Bug: function_choice_behavior config not work #12559

Open
@MayueCif

Description

@MayueCif

Describe the bug
agent-templates create agent,function_choice_behavior not work.

To Reproduce
yaml

execution_settings:
  default:
    temperature: 0.0
    top_p: 0.0
    top_k: 1
    function_choice_behavior:
      type: auto

Expected behavior

PromptTemplateConfig templateConfig = KernelFunctionYaml.ToPromptTemplateConfig(yamlContent);
ChatCompletionAgent chatCompletionAgent =
    new ChatCompletionAgent(templateConfig, new KernelPromptTemplateFactory())
    {
        Kernel = _kernel,
        Arguments = new KernelArguments
        {
            { "global_analysis_guidelines", globalGuidelines },
        }
    };

chatCompletionAgent InvokeAsync can not call function,Change to the following writing style

PromptTemplateConfig templateConfig = KernelFunctionYaml.ToPromptTemplateConfig(yamlContent);

var promptExecutionSettings = new OpenAIPromptExecutionSettings()
{
    FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(options: new()
    {
        AllowParallelCalls = true,
        AllowStrictSchemaAdherence = true,
        RetainArgumentTypes = true
    })
};

ChatCompletionAgent chatCompletionAgent =
    new ChatCompletionAgent(templateConfig, new KernelPromptTemplateFactory())
    {
        Kernel = _kernel,
        Arguments = new KernelArguments
        {
            { "global_analysis_guidelines", globalGuidelines },
        }
    };

it work,why?

Platform

  • Language: [C#]
  • Source: [1.56.0]
  • AI model: [Qwen3-32B]
  • IDE: [Visual Studio,]
  • OS: [Windows]

Metadata

Metadata

Labels

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

Type

Projects

Status

Bug

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions