{"record":{"id":"da824851a8ed837d","repo":"microsoft/autogen","slug":"unsupported-message-type","errorCode":null,"errorMessage":"Unsupported message type","messagePattern":"Unsupported message type","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/AutoGen.SemanticKernel/Middleware/SemanticKernelChatMessageContentConnector.cs","lineNumber":243,"sourceCode":"\n    [Obsolete(\"This method is deprecated, please use the specific method instead.\")]\n    private IEnumerable<ChatMessageContent> ProcessMessageForSelf(Message message)\n    {\n        if (message.Role == Role.System)\n        {\n            return [new ChatMessageContent(AuthorRole.System, message.Content)];\n        }\n        else if (message.Content is string && message.FunctionName is null && message.FunctionArguments is null)\n        {\n            return [new ChatMessageContent(AuthorRole.Assistant, message.Content)];\n        }\n        else if (message.Content is null && message.FunctionName is not null && message.FunctionArguments is not null)\n        {\n            throw new System.InvalidOperationException(\"Function call is not supported in the semantic kernel if it's from self.\");\n        }\n        else\n        {\n            throw new System.InvalidOperationException(\"Unsupported message type\");\n        }\n    }\n\n    [Obsolete(\"This method is deprecated, please use the specific method instead.\")]\n    private IEnumerable<ChatMessageContent> ProcessMessageForOthers(Message message)\n    {\n        if (message.Role == Role.System)\n        {\n            return [new ChatMessageContent(AuthorRole.System, message.Content)];\n        }\n        else if (message.Content is string && message.FunctionName is null && message.FunctionArguments is null)\n        {\n            return [new ChatMessageContent(AuthorRole.User, message.Content)];\n        }\n        else if (message.Content is null && message.FunctionName is not null && message.FunctionArguments is not null)\n        {\n            throw new System.InvalidOperationException(\"Function call is not supported in the semantic kernel if it's from others.\");\n        }","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.SemanticKernel/Middleware/SemanticKernelChatMessageContentConnector.cs#L225-L261","documentation":"Thrown by SemanticKernelChatMessageContentConnector.ProcessMessageForSelf when a Message from the agent itself does not match any supported shape. The connector only accepts: (a) string content with null FunctionName/FunctionArguments, or (b) null content with both FunctionName and FunctionArguments set (which is then rejected separately). Any other combination falls into the final else and raises this InvalidOperationException.","triggerScenarios":"Passing a Message to the SemanticKernel middleware where Content is not a string (e.g. multimodal content or an IList), or where FunctionName is set but FunctionArguments is null (or vice versa), or where both string content and a function call are present at once.","commonSituations":"Replaying a captured function-call message that was serialized and lost one field (arguments null after round-trip), mixing tool output with function name, or feeding a MultiModalMessage/ToolMessage content object into a SemanticKernel agent pipeline that expects plain chat text.","solutions":["Ensure the message passed for 'self' history has plain string Content with FunctionName and FunctionArguments both null","If the message carries a function call, set Content to null AND populate both FunctionName and FunctionArguments as non-null strings (though that path throws separately in this connector)","Convert multimodal or structured content to a string (e.g. serialize/collapse to text) before sending to a SemanticKernel agent","Upgrade AutoGen.SemanticKernel to a newer 0.4x+ version where message processing was reworked to support function-call history"],"exampleFix":"// before\nvar msg = new Message(Role.Assistant, from: agentName)\n{\n    Content = resultJson,\n    FunctionName = \"get_weather\", // FunctionArguments left null -> falls to 'Unsupported message type'\n};\n\n// after\nvar msg = new Message(Role.Assistant, content: \"Called get_weather\", from: agentName); // plain string, no function fields","handlingStrategy":"validation","validationCode":"bool IsSupportedSelfMessage(Message m) =>\n    (m.Content is string && m.FunctionName is null && m.FunctionArguments is null)\n    || (m.Content is null && m.FunctionName is not null && m.FunctionArguments is not null);\n\nvar safe = messages.Where(IsSupportedSelfMessage);","typeGuard":"static bool IsSupportedSelfMessage(Message m) =>\n    m.Content is string && m.FunctionName is null && m.FunctionArguments is null;","tryCatchPattern":"try { await skAgent.SendAsync(msg); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Unsupported message type\"))\n{\n    _logger.LogWarning(\"Dropping unsupported self message {Type}\", msg.Content?.GetType()); // drop and continue\n}","preventionTips":["Always keep Content a plain string when no function call is attached","Never mix string content with FunctionName/FunctionArguments on the same message","Log Content type plus FunctionName/FunctionArguments null-state before dispatching to SemanticKernel agents"],"tags":["csharp","semantic-kernel","message-conversion","invalid-operation"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}