Skip to content

.Net: Bug: Chat Completion Agent with Open AI o1-preview is not working out of the box #10272

Closed
@fgauna12

Description

@fgauna12

Describe the bug
Can't use Open AI o1-preview model with ChatCompletionAgent because it fails with the following exception.

Microsoft.SemanticKernel.HttpOperationException: HTTP 400 (invalid_request_error: unsupported_value)

Microsoft.SemanticKernel.HttpOperationException
HTTP 400 (invalid_request_error: unsupported_value)
Parameter: messages[0].role

Unsupported value: 'messages[0].role' does not support 'system' with this model.

To Reproduce
Steps to reproduce the behavior:

[Fact]
    public async Task ThisFailsAndISad()
    {
        var instructions =
            "You are a cat. You're an expert meower.";

        var configuration = new ConfigurationBuilder()
            .AddUserSecrets<SamplePromptsIntegrationTests>()
            .Build();

        var services = new ServiceCollection();

        services.AddLogging();

        var kernel = Kernel.CreateBuilder()
            .AddOpenAIChatCompletion("o1-preview", configuration["OpenAI:APIKey"]!)
            .Build();

#pragma warning disable SKEXP0110
        var agent = new ChatCompletionAgent()
        {
            Kernel = kernel,
            Instructions = instructions
        };

        ChatHistory chat =
        [
            new ChatMessageContent(AuthorRole.User, "Hello")
        ];

        await foreach (ChatMessageContent response in agent.InvokeAsync(chat))
        {
            response.Content?.ToLowerInvariant().Should().Contain("meow");
        }
#pragma warning restore SKEXP0110
    }

Expected behavior
It should just work. 🙃

Screenshots
Nah.

Platform

  • OS: Windows 11
  • IDE: Rider
  • Language: C#
  • Source:
        <PackageReference Include="Microsoft.SemanticKernel" Version="1.34.0" />
        <PackageReference Include="Microsoft.SemanticKernel.Agents.Core" Version="1.34.0-alpha" />

Additional context
Nerp.

Metadata

Metadata

Assignees

Labels

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

Type

Projects

Status

Bug

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions