microsoft/autogen · error · InvalidOperationException
Unsupported content type
Error message
Unsupported content type
What it means
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'.
Source
Thrown at dotnet/src/AutoGen.SemanticKernel/Middleware/SemanticKernelChatMessageContentConnector.cs:88
private IMessage PostProcessStreamingMessage(IMessage input)
{
return input switch
{
IMessage<StreamingChatMessageContent> streamingMessage => PostProcessMessage(streamingMessage),
IMessage msg => PostProcessMessage(msg),
_ => input,
};
}
private IMessage PostProcessMessage(IMessage<ChatMessageContent> messageEnvelope)
{
var chatMessageContent = messageEnvelope.Content;
var items = chatMessageContent.Items.Select<KernelContent, IMessage>(i => i switch
{
TextContent txt => new TextMessage(Role.Assistant, txt.Text!, messageEnvelope.From),
ImageContent img when img.Uri is Uri uri => new ImageMessage(Role.Assistant, uri.ToString(), from: messageEnvelope.From),
ImageContent img when img.Data is ReadOnlyMemory<byte> data => new ImageMessage(Role.Assistant, BinaryData.FromBytes(data), from: messageEnvelope.From),
_ => throw new InvalidOperationException("Unsupported content type"),
});
if (items.Count() == 1)
{
return items.First();
}
else
{
return new MultiModalMessage(Role.Assistant, items, from: messageEnvelope.From);
}
}
private IMessage PostProcessMessage(IMessage<StreamingChatMessageContent> streamingMessage)
{
var chatMessageContent = streamingMessage.Content;
if (chatMessageContent.ChoiceIndex > 0)
{
throw new InvalidOperationException("Only one choice is supported in streaming response");View on GitHub (pinned to 027ecf0a37)
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.
Example fix
// before
var settings = new OpenAIPromptExecutionSettings { ToolCallBehavior = null }; // tool calls leak into content
// after
var settings = new OpenAIPromptExecutionSettings { ToolCallBehavior = ToolCallBehavior.AutoInvokeKernelFunctions }; Defensive patterns
Strategy: type-guard
Validate before calling
// Before post-processing, verify all items are convertible
var 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();
if (unsupported.Count > 0) { /* extract FunctionCallContent yourself or reconfigure SK */ } Type guard
static bool IsSupportedKernelContent(KernelContent c) => c switch
{
TextContent => true,
ImageContent img => img.Uri is not null || img.Data is not null,
_ => false,
}; Try / catch
catch (InvalidOperationException ex) when (ex.Message == "Unsupported content type")
{
logger.LogError("SK returned non text/image content (likely FunctionCallContent). Enable auto function invocation.");
throw;
} Prevention
- Enable ToolCallBehavior.AutoInvokeKernelFunctions so function calls never surface as content items.
- Pin compatible AutoGen/SK versions in one package reference set.
When it happens
Trigger: The SK chat completion returns content items such as FunctionCallContent (auto function invocation disabled), AudioContent, or BinaryContent instead of plain text/image parts.
Common situations: 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.
Related errors
- Invalid ChatResponseMessage
- Missing parameter type for {parameterName}
- Missing required parameter: {parameterName}
- Only one choice is supported in streaming response
- The method or operation is not implemented.
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/77971f5fa8942aa3.
Report an issue: GitHub.