{"record":{"id":"77971f5fa8942aa3","repo":"microsoft/autogen","slug":"unsupported-content-type","errorCode":null,"errorMessage":"Unsupported content type","messagePattern":"Unsupported content type","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/AutoGen.SemanticKernel/Middleware/SemanticKernelChatMessageContentConnector.cs","lineNumber":88,"sourceCode":"    private IMessage PostProcessStreamingMessage(IMessage input)\n    {\n        return input switch\n        {\n            IMessage<StreamingChatMessageContent> streamingMessage => PostProcessMessage(streamingMessage),\n            IMessage msg => PostProcessMessage(msg),\n            _ => input,\n        };\n    }\n\n    private IMessage PostProcessMessage(IMessage<ChatMessageContent> messageEnvelope)\n    {\n        var chatMessageContent = messageEnvelope.Content;\n        var items = chatMessageContent.Items.Select<KernelContent, IMessage>(i => i switch\n        {\n            TextContent txt => new TextMessage(Role.Assistant, txt.Text!, messageEnvelope.From),\n            ImageContent img when img.Uri is Uri uri => new ImageMessage(Role.Assistant, uri.ToString(), from: messageEnvelope.From),\n            ImageContent img when img.Data is ReadOnlyMemory<byte> data => new ImageMessage(Role.Assistant, BinaryData.FromBytes(data), from: messageEnvelope.From),\n            _ => throw new InvalidOperationException(\"Unsupported content type\"),\n        });\n\n        if (items.Count() == 1)\n        {\n            return items.First();\n        }\n        else\n        {\n            return new MultiModalMessage(Role.Assistant, items, from: messageEnvelope.From);\n        }\n    }\n\n    private IMessage PostProcessMessage(IMessage<StreamingChatMessageContent> streamingMessage)\n    {\n        var chatMessageContent = streamingMessage.Content;\n        if (chatMessageContent.ChoiceIndex > 0)\n        {\n            throw new InvalidOperationException(\"Only one choice is supported in streaming response\");","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.SemanticKernel/Middleware/SemanticKernelChatMessageContentConnector.cs#L70-L106","documentation":"SemanticKernelChatMessageContentConnector.PostProcessMessage converts each item of a SK ChatMessageContent into AutoGen messages. Only TextContent and ImageContent (with Uri or Data) are supported; any other KernelContent-derived item — notably FunctionCallContent — throws 'Unsupported content type'.","triggerScenarios":"The SK chat completion returns content items such as FunctionCallContent (auto function invocation disabled), AudioContent, or BinaryContent instead of plain text/image parts.","commonSituations":"Auto function-calling is turned off (or tool calls arrive as content rather than the ToolCalls property), so function-call payloads surface in ChatMessageContent.Items; using newer SK content kinds this connector predates.","solutions":["Enable SK auto function invocation (ToolCallBehavior) so function calls are resolved before content reaches the connector, or route function-call completions through a connector that handles them.","Configure the agent so tool calls land in the tool-call channel rather than content items.","Update AutoGen to a version whose SK connector supports the content kinds your SK version emits.","Intercept IMessage<ChatMessageContent> yourself and extract FunctionCallContent before post-processing."],"exampleFix":"// before\nvar settings = new OpenAIPromptExecutionSettings { ToolCallBehavior = null }; // tool calls leak into content\n\n// after\nvar settings = new OpenAIPromptExecutionSettings { ToolCallBehavior = ToolCallBehavior.AutoInvokeKernelFunctions };","handlingStrategy":"type-guard","validationCode":"// Before post-processing, verify all items are convertible\nvar unsupported = chatMessageContent.Items.Where(i => i is not TextContent && i is not (ImageContent ic when ic.Uri is not null || ic.Data is not null)).ToList();\nif (unsupported.Count > 0) { /* extract FunctionCallContent yourself or reconfigure SK */ }","typeGuard":"static bool IsSupportedKernelContent(KernelContent c) => c switch\n{\n    TextContent => true,\n    ImageContent img => img.Uri is not null || img.Data is not null,\n    _ => false,\n};","tryCatchPattern":"catch (InvalidOperationException ex) when (ex.Message == \"Unsupported content type\")\n{\n    logger.LogError(\"SK returned non text/image content (likely FunctionCallContent). Enable auto function invocation.\");\n    throw;\n}","preventionTips":["Enable ToolCallBehavior.AutoInvokeKernelFunctions so function calls never surface as content items.","Pin compatible AutoGen/SK versions in one package reference set."],"tags":["semantic-kernel","content-type","function-calling","autogen","csharp"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}