{"record":{"id":"81095444ed689fc3","repo":"microsoft/autogen","slug":"messages-should-not-be-provided-in-options","errorCode":null,"errorMessage":"Messages should not be provided in options","messagePattern":"Messages should not be provided in options","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/AutoGen.AzureAIInference/Agent/ChatCompletionsClientAgent.cs","lineNumber":84,"sourceCode":"    {\n    }\n\n    /// <summary>\n    /// Create a new instance of <see cref=\"ChatCompletionsClientAgent\"/>.\n    /// </summary>\n    /// <param name=\"chatCompletionsClient\">chat completions client</param>\n    /// <param name=\"name\">agent name</param>\n    /// <param name=\"systemMessage\">system message</param>\n    /// <param name=\"options\">chat completion option. The option can't contain messages</param>\n    public ChatCompletionsClientAgent(\n        ChatCompletionsClient chatCompletionsClient,\n        string name,\n        ChatCompletionsOptions options,\n        string systemMessage = \"You are a helpful AI assistant\")\n    {\n        if (options.Messages is { Count: > 0 })\n        {\n            throw new ArgumentException(\"Messages should not be provided in options\");\n        }\n\n        this.chatCompletionsClient = chatCompletionsClient;\n        this.Name = name;\n        this.options = options;\n        this.systemMessage = systemMessage;\n    }\n\n    public string Name { get; }\n\n    public async Task<IMessage> GenerateReplyAsync(\n        IEnumerable<IMessage> messages,\n        GenerateReplyOptions? options = null,\n        CancellationToken cancellationToken = default)\n    {\n        var settings = this.CreateChatCompletionsOptions(options, messages);\n        var reply = await this.chatCompletionsClient.CompleteAsync(settings, cancellationToken: cancellationToken);\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.AzureAIInference/Agent/ChatCompletionsClientAgent.cs#L66-L102","documentation":"Error \"Messages should not be provided in options\" thrown in microsoft/autogen.","triggerScenarios":"Thrown at dotnet/src/AutoGen.AzureAIInference/Agent/ChatCompletionsClientAgent.cs:84 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create fresh options per call instead of reusing options that carry messages"],"exampleFix":"new ChatCompletionsOptions() without pre-populated Messages, or clear options.Messages","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}