Skip to content

.Net: Bug: Function call with complex objects fails with o3-mini #11509

Closed
@AlesRuzickaEu

Description

@AlesRuzickaEu

Describe the bug
Function call with complex object and optional values fail with o3-mini (works with gpt-4o)

To Reproduce

Minimal code:

var builder = Kernel
    .CreateBuilder();

builder.AddOpenAIChatCompletion("o3-mini", apiKey);

var kernel = builder.Build();

kernel.Plugins.AddFromType<Plugin>("Plugin");

var chatCompletionServices = kernel.GetRequiredService<IChatCompletionService>();

var promptExecutionSettings = new OpenAIPromptExecutionSettings
{
    FunctionChoiceBehavior = FunctionChoiceBehavior.Required(options: new FunctionChoiceBehaviorOptions
    {
        AllowStrictSchemaAdherence = true,
    })
};

var history = new ChatHistory();

history.AddUserMessage("Generate name as 'a'");

var result = await chatCompletionServices.GetChatMessageContentAsync(history, promptExecutionSettings, kernel);

class Plugin
{
    [KernelFunction("generate")]
    public void Generate(Result result)
    {
    }
}

public class Result
{
    public string? Name { get; set; }
}

Expected behavior
Expect function call with complex object

Actual behavior
Throws Error:
Microsoft.SemanticKernel.HttpOperationException: 'HTTP 400 (invalid_request_error: )

Invalid schema for function 'Plugin-generate': In context=('properties', 'result', 'properties', 'Name'), schema must have a 'type' key.'

Platform

  • Language: C#
  • Source: NuGet package version 1.45.0
  • AI model: OpenAI:o3-mini
  • IDE: Visual Studio
  • OS: Windows

Additional context
Add any other context about the problem here.

Metadata

Metadata

Labels

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

Type

Projects

Status

Sprint: Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions