microsoft/autogen · error · ArgumentException
ImageMessage is not supported when message.From is the same
Error message
ImageMessage is not supported when message.From is the same with agent
What it means
Error "ImageMessage is not supported when message.From is the same with agent" thrown in microsoft/autogen.
Source
Thrown at dotnet/src/AutoGen.AzureAIInference/Middleware/AzureAIInferenceChatRequestMessageConnector.cs:225
}
else
{
return message.From switch
{
null when message.Role == Role.User => [new ChatRequestUserMessage(message.Content)],
null when message.Role == Role.Assistant => [new ChatRequestAssistantMessage() { Content = message.Content }],
null => throw new InvalidOperationException("Invalid Role"),
_ => [new ChatRequestUserMessage(message.Content)]
};
}
}
private IEnumerable<ChatRequestMessage> ProcessImageMessage(IAgent agent, ImageMessage message)
{
if (agent.Name == message.From)
{
// image message from assistant is not supported
throw new ArgumentException("ImageMessage is not supported when message.From is the same with agent");
}
var imageContentItem = this.CreateChatMessageImageContentItemFromImageMessage(message);
return [new ChatRequestUserMessage([imageContentItem])];
}
private IEnumerable<ChatRequestMessage> ProcessMultiModalMessage(IAgent agent, MultiModalMessage message)
{
if (agent.Name == message.From)
{
// image message from assistant is not supported
throw new ArgumentException("MultiModalMessage is not supported when message.From is the same with agent");
}
IEnumerable<ChatMessageContentItem> items = message.Content.Select<IMessage, ChatMessageContentItem>(ci => ci switch
{
TextMessage text => new ChatMessageTextContentItem(text.Content),
ImageMessage image => this.CreateChatMessageImageContentItemFromImageMessage(image),View on GitHub (pinned to 027ecf0a37)
Solutions
- Images from the assistant are not supported; only user messages may carry images
Example fix
Do not attach ImageMessage with From equal to the agent name
When it happens
Trigger: Thrown at dotnet/src/AutoGen.AzureAIInference/Middleware/AzureAIInferenceChatRequestMessageConnector.cs:225 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/3c73e7331fa5b51e.
Report an issue: GitHub.