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
ProcessImageMessage refuses to convert an ImageMessage whose From equals the receiving agent's name: OpenAI's chat protocol has no concept of an assistant-authored image user message, so replaying an agent's own image output back into its history cannot be represented.
Source
Thrown at dotnet/src/AutoGen.OpenAI/Middleware/OpenAIChatRequestMessageConnector.cs:270
}
else
{
return message.From switch
{
null when message.Role == Role.User => [new UserChatMessage(message.Content)],
null when message.Role == Role.Assistant => [new AssistantChatMessage(message.Content)],
null => throw new InvalidOperationException("Invalid Role"),
_ => [new UserChatMessage(message.Content) { ParticipantName = message.From }]
};
}
}
private IEnumerable<ChatMessage> 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 UserChatMessage([imageContentItem]) { ParticipantName = message.From }];
}
private IEnumerable<ChatMessage> 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<ChatMessageContentPart> items = message.Content.Select<IMessage, ChatMessageContentPart>(ci => ci switch
{
TextMessage text => ChatMessageContentPart.CreateTextPart(text.Content),
ImageMessage image => this.CreateChatMessageImageContentItemFromImageMessage(image),View on GitHub (pinned to 027ecf0a37)
Solutions
- Filter self-authored image messages out of the history before calling the agent (skip ImageMessage where From == agent.Name).
- Re-label the message with From = null or the user's name if the image genuinely must be shown to the agent as input.
- Use non-strict connector mode plus prior filtering so self-images are dropped rather than converted.
Example fix
// before var history = allMessages; // includes agent's own ImageMessage await agent.SendAsync(history); // after var history = allMessages.Where(m => m is not ImageMessage im || im.From != agent.Name); await agent.SendAsync(history);
Defensive patterns
Strategy: validation
Validate before calling
var safeHistory = messages.Where(m => m is not ImageMessage img || img.From != agent.Name).ToList(); await agent.SendAsync(safeHistory);
Type guard
static bool IsReplayableToAgent(IMessage m, string agentName) => m switch
{
ImageMessage img => img.From != agentName,
_ => true,
}; Try / catch
catch (ArgumentException ex) when (ex.Message.Contains("ImageMessage is not supported"))
{
var filtered = messages.Where(m => m is not ImageMessage im || im.From != agent.Name);
return await agent.SendAsync(filtered);
} Prevention
- In group chats, always filter self-authored image/multimodal messages per recipient.
- Keep a single history-normalization step before any agent call.
When it happens
Trigger: In a group chat or manual history replay, an ImageMessage created with from: agent.Name (or produced by that agent) is sent to the same agent.
Common situations: Round-robin group chats where every agent sees all messages including its own prior outputs; copying assistant image replies into the next request unmodified.
Related errors
- MultiModalMessage is not supported when message.From is the
- ToolCallMessage is not supported when message.From is not th
- Please set OPENAI_API_KEY environment variable.
- Please set OPENAI_API_KEY environment variable.
- ImageMessage is not supported when message.From is the same
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/6519f6aa299b2791.
Report an issue: GitHub.