microsoft/autogen · error · ArgumentException

Messages should not be provided in options

Error message

Messages should not be provided in options

What it means

Error "Messages should not be provided in options" thrown in microsoft/autogen.

Source

Thrown at dotnet/src/AutoGen.AzureAIInference/Agent/ChatCompletionsClientAgent.cs:84

    {
    }

    /// <summary>
    /// Create a new instance of <see cref="ChatCompletionsClientAgent"/>.
    /// </summary>
    /// <param name="chatCompletionsClient">chat completions client</param>
    /// <param name="name">agent name</param>
    /// <param name="systemMessage">system message</param>
    /// <param name="options">chat completion option. The option can't contain messages</param>
    public ChatCompletionsClientAgent(
        ChatCompletionsClient chatCompletionsClient,
        string name,
        ChatCompletionsOptions options,
        string systemMessage = "You are a helpful AI assistant")
    {
        if (options.Messages is { Count: > 0 })
        {
            throw new ArgumentException("Messages should not be provided in options");
        }

        this.chatCompletionsClient = chatCompletionsClient;
        this.Name = name;
        this.options = options;
        this.systemMessage = systemMessage;
    }

    public string Name { get; }

    public async Task<IMessage> GenerateReplyAsync(
        IEnumerable<IMessage> messages,
        GenerateReplyOptions? options = null,
        CancellationToken cancellationToken = default)
    {
        var settings = this.CreateChatCompletionsOptions(options, messages);
        var reply = await this.chatCompletionsClient.CompleteAsync(settings, cancellationToken: cancellationToken);

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Create fresh options per call instead of reusing options that carry messages

Example fix

new ChatCompletionsOptions() without pre-populated Messages, or clear options.Messages

When it happens

Trigger: Thrown at dotnet/src/AutoGen.AzureAIInference/Agent/ChatCompletionsClientAgent.cs:84 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/81095444ed689fc3. Report an issue: GitHub.