microsoft/autogen · error · InvalidOperationException
Invalid Message as message from other.
Error message
Invalid Message as message from other.
What it means
Thrown from the legacy Message path (ProcessIncomingMessagesForOther/ProcessMessage) when a Message from another party has null/empty content and no FunctionName, so it can't be mapped to a ChatRequestUserMessage or ChatRequestToolMessage. The connector refuses to fabricate a user message from nothing.
Source
Thrown at dotnet/src/AutoGen.OpenAI.V1/Middleware/OpenAIChatRequestMessageConnector.cs:265
{
return [new ChatRequestSystemMessage(message.Content) { Name = message.From }];
}
else if (message.Content is string content && content is { Length: > 0 })
{
if (message.FunctionName is not null)
{
return new[] { new ChatRequestToolMessage(content, message.FunctionName) };
}
return [new ChatRequestUserMessage(message.Content) { Name = message.From }];
}
else if (message.FunctionName is string _)
{
return [new ChatRequestUserMessage("// Message type is not supported") { Name = message.From }];
}
else
{
throw new InvalidOperationException("Invalid Message as message from other.");
}
}
private IEnumerable<ChatRequestMessage> ProcessTextMessage(IAgent agent, TextMessage message)
{
if (message.Role == Role.System)
{
return [new ChatRequestSystemMessage(message.Content) { Name = message.From }];
}
if (agent.Name == message.From)
{
return [new ChatRequestAssistantMessage(message.Content) { Name = agent.Name }];
}
else
{
return message.From switch
{View on GitHub (pinned to 027ecf0a37)
Solutions
- Filter out or skip empty legacy messages before sending the conversation to the agent
- Give the message non-empty Content or a FunctionName so it maps to ChatRequestUserMessage/ChatRequestToolMessage
- Migrate message production code to TextMessage so the legacy branch is never hit
Example fix
// before messages.Add(new Message(Role.User, content: null, from: "User")); // throws // after messages.Add(new Message(Role.User, content: "(empty turn)", from: "User")); // or better: new TextMessage(Role.User, "(empty turn)", from: "User")
Defensive patterns
Strategy: validation
Validate before calling
if (msg is Message { Content: null or "" , FunctionName: null }) { /* skip or give placeholder content */ } Try / catch
catch (InvalidOperationException ex) when (ex.Message == "Invalid Message as message from other.") { /* filter empty legacy messages from history */ } Prevention
- Filter empty messages when loading conversation logs
- Migrate to TextMessage
- Ensure upstream agents never emit empty legacy Messages
When it happens
Trigger: A legacy Message with From != agent.Name, Content null or empty string, and FunctionName null, passed through ProcessIncomingMessages.
Common situations: Replaying old conversation logs that contain empty filler messages; upstream agent emitting an empty legacy Message on error; migration from the deprecated Message API.
Related errors
- Invalid Message as message from self.
- Please set AZURE_OPENAI_API_KEY environment variable.
- Please set AZURE_OPENAI_ENDPOINT environment variable.
- Please set environment variable AZURE_OPENAI_API_KEY
- Invalid return message type {message.GetType().Name}
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/67d15a4e9ebd5f81.
Report an issue: GitHub.