microsoft/autogen · error · InvalidOperationException

unsupported message type, only support TextMessage, ImageMes

Error message

unsupported message type, only support TextMessage, ImageMessage, MultiModalMessage and Message.

What it means

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.

Source

Thrown at dotnet/src/AutoGen.SemanticKernel/Middleware/SemanticKernelChatMessageContentConnector.cs:153

            MultiModalMessage multiModalMessage => ProcessMessageForSelf(multiModalMessage),
#pragma warning disable CS0618 // deprecated
            Message m => ProcessMessageForSelf(m),
#pragma warning restore CS0618 // deprecated
            _ => throw new System.NotImplementedException(),
        };
    }

    private IEnumerable<ChatMessageContent> ProcessMessageForOthers(IMessage message)
    {
        return message switch
        {
            TextMessage textMessage => ProcessMessageForOthers(textMessage),
            MultiModalMessage multiModalMessage => ProcessMessageForOthers(multiModalMessage),
            ImageMessage imageMessage => ProcessMessageForOthers(imageMessage),
#pragma warning disable CS0618 // deprecated
            Message m => ProcessMessageForOthers(m),
#pragma warning restore CS0618 // deprecated
            _ => throw new InvalidOperationException("unsupported message type, only support TextMessage, ImageMessage, MultiModalMessage and Message."),
        };
    }

    private IEnumerable<ChatMessageContent> ProcessMessageForSelf(TextMessage message)
    {
        if (message.Role == Role.System)
        {
            return [new ChatMessageContent(AuthorRole.System, message.Content)];
        }
        else
        {
            return [new ChatMessageContent(AuthorRole.Assistant, message.Content)];
        }
    }

    private IEnumerable<ChatMessageContent> ProcessMessageForOthers(TextMessage message)
    {
        if (message.Role == Role.System)

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Pre-filter messages so SK agents only receive TextMessage, ImageMessage, MultiModalMessage, or Message.
  2. Convert tool-call traffic into a textual transcript (e.g. 'agent-a called F(args) -> result') as TextMessage before sending.
  3. Attach a middleware that translates unsupported types ahead of the SK connector.
  4. Catch and log the offending message type to identify which orchestrator path emits it.

Example fix

// before
await skAgent.SendAsync(conversationWithToolCalls);

// after
var skSafe = conversation.Where(m => m is TextMessage or ImageMessage or MultiModalMessage or Message);
await skAgent.SendAsync(skSafe);
Defensive patterns

Strategy: type-guard

Validate before calling

var skSafe = messages.Where(m => m is TextMessage or ImageMessage or MultiModalMessage or Message).ToList();
await skAgent.SendAsync(skSafe);

Type guard

static bool IsSupportedOtherMessage(IMessage m) => m is TextMessage or ImageMessage or MultiModalMessage or Message;

Try / catch

catch (InvalidOperationException ex) when (ex.Message.StartsWith("unsupported message type"))
{
    logger.LogError("Dropping unsupported message for SK agent");
    return await skAgent.SendAsync(messages.Where(IsSupportedOtherMessage));
}

Prevention

When it happens

Trigger: Sending a conversation that includes another agent's tool-call traffic or a custom IMessage subclass through SemanticKernelChatMessageContentConnector.

Common situations: Multi-agent orchestrations where SK agents observe tool-use between other agents; custom envelope messages not normalized before dispatch.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/40453995791d711a. Report an issue: GitHub.