{"record":{"id":"40453995791d711a","repo":"microsoft/autogen","slug":"unsupported-message-type-only-support-textmessage","errorCode":null,"errorMessage":"unsupported message type, only support TextMessage, ImageMessage, MultiModalMessage and Message.","messagePattern":"unsupported message type, only support TextMessage, ImageMessage, MultiModalMessage and Message\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/AutoGen.SemanticKernel/Middleware/SemanticKernelChatMessageContentConnector.cs","lineNumber":153,"sourceCode":"            MultiModalMessage multiModalMessage => ProcessMessageForSelf(multiModalMessage),\n#pragma warning disable CS0618 // deprecated\n            Message m => ProcessMessageForSelf(m),\n#pragma warning restore CS0618 // deprecated\n            _ => throw new System.NotImplementedException(),\n        };\n    }\n\n    private IEnumerable<ChatMessageContent> ProcessMessageForOthers(IMessage message)\n    {\n        return message switch\n        {\n            TextMessage textMessage => ProcessMessageForOthers(textMessage),\n            MultiModalMessage multiModalMessage => ProcessMessageForOthers(multiModalMessage),\n            ImageMessage imageMessage => ProcessMessageForOthers(imageMessage),\n#pragma warning disable CS0618 // deprecated\n            Message m => ProcessMessageForOthers(m),\n#pragma warning restore CS0618 // deprecated\n            _ => throw new InvalidOperationException(\"unsupported message type, only support TextMessage, ImageMessage, MultiModalMessage and Message.\"),\n        };\n    }\n\n    private IEnumerable<ChatMessageContent> ProcessMessageForSelf(TextMessage message)\n    {\n        if (message.Role == Role.System)\n        {\n            return [new ChatMessageContent(AuthorRole.System, message.Content)];\n        }\n        else\n        {\n            return [new ChatMessageContent(AuthorRole.Assistant, message.Content)];\n        }\n    }\n\n    private IEnumerable<ChatMessageContent> ProcessMessageForOthers(TextMessage message)\n    {\n        if (message.Role == Role.System)","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.SemanticKernel/Middleware/SemanticKernelChatMessageContentConnector.cs#L135-L171","documentation":"ProcessMessageForOthers converts messages from other participants into SK ChatMessageContent and supports TextMessage, MultiModalMessage, ImageMessage, and the deprecated Message. Any other IMessage type (ToolCallMessage from another agent, ToolCallResultMessage, AggregateMessage, custom types) throws this InvalidOperationException.","triggerScenarios":"Sending a conversation that includes another agent's tool-call traffic or a custom IMessage subclass through SemanticKernelChatMessageContentConnector.","commonSituations":"Multi-agent orchestrations where SK agents observe tool-use between other agents; custom envelope messages not normalized before dispatch.","solutions":["Pre-filter messages so SK agents only receive TextMessage, ImageMessage, MultiModalMessage, or Message.","Convert tool-call traffic into a textual transcript (e.g. 'agent-a called F(args) -> result') as TextMessage before sending.","Attach a middleware that translates unsupported types ahead of the SK connector.","Catch and log the offending message type to identify which orchestrator path emits it."],"exampleFix":"// before\nawait skAgent.SendAsync(conversationWithToolCalls);\n\n// after\nvar skSafe = conversation.Where(m => m is TextMessage or ImageMessage or MultiModalMessage or Message);\nawait skAgent.SendAsync(skSafe);","handlingStrategy":"type-guard","validationCode":"var skSafe = messages.Where(m => m is TextMessage or ImageMessage or MultiModalMessage or Message).ToList();\nawait skAgent.SendAsync(skSafe);","typeGuard":"static bool IsSupportedOtherMessage(IMessage m) => m is TextMessage or ImageMessage or MultiModalMessage or Message;","tryCatchPattern":"catch (InvalidOperationException ex) when (ex.Message.StartsWith(\"unsupported message type\"))\n{\n    logger.LogError(\"Dropping unsupported message for SK agent\");\n    return await skAgent.SendAsync(messages.Where(IsSupportedOtherMessage));\n}","preventionTips":["Route tool-call traffic through a dedicated tool-call-aware middleware, not the plain SK content connector.","Add a message-normalization middleware in front of SK agents."],"tags":["semantic-kernel","message-connector","group-chat","autogen","csharp"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}