{"record":{"id":"1139b0bf0a839a54","repo":"microsoft/autogen","slug":"invalid-message-type","errorCode":null,"errorMessage":"Invalid message type","messagePattern":"Invalid message type","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/AutoGen.AzureAIInference/Agent/ChatCompletionsClientAgent.cs","lineNumber":124,"sourceCode":"    public async IAsyncEnumerable<IMessage> GenerateStreamingReplyAsync(\n        IEnumerable<IMessage> messages,\n        GenerateReplyOptions? options = null,\n        [EnumeratorCancellation] CancellationToken cancellationToken = default)\n    {\n        var settings = this.CreateChatCompletionsOptions(options, messages);\n        var response = await this.chatCompletionsClient.CompleteStreamingAsync(settings, cancellationToken);\n        await foreach (var update in response.WithCancellation(cancellationToken))\n        {\n            yield return new MessageEnvelope<StreamingChatCompletionsUpdate>(update, from: this.Name);\n        }\n    }\n\n    private ChatCompletionsOptions CreateChatCompletionsOptions(GenerateReplyOptions? options, IEnumerable<IMessage> messages)\n    {\n        var oaiMessages = messages.Select(m => m switch\n        {\n            IMessage<ChatRequestMessage> chatRequestMessage => chatRequestMessage.Content,\n            _ => throw new ArgumentException(\"Invalid message type\")\n        });\n\n        // add system message if there's no system message in messages\n        if (!oaiMessages.Any(m => m is ChatRequestSystemMessage))\n        {\n            oaiMessages = new[] { new ChatRequestSystemMessage(systemMessage) }.Concat(oaiMessages);\n        }\n\n        // clone the options by serializing and deserializing\n        var json = JsonSerializer.Serialize(this.options);\n        var settings = JsonSerializer.Deserialize<ChatCompletionsOptions>(json) ?? throw new InvalidOperationException(\"Failed to clone options\");\n\n        foreach (var m in oaiMessages)\n        {\n            settings.Messages.Add(m);\n        }\n\n        settings.Temperature = options?.Temperature ?? settings.Temperature;","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.AzureAIInference/Agent/ChatCompletionsClientAgent.cs#L106-L142","documentation":"Error \"Invalid message type\" thrown in microsoft/autogen.","triggerScenarios":"Thrown at dotnet/src/AutoGen.AzureAIInference/Agent/ChatCompletionsClientAgent.cs:124 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass only TextMessage, ImageMessage, MultiModalMessage, or ToolCallMessage"],"exampleFix":"Convert the message to a supported IMessage type before invoking the agent","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"}