{"record":{"id":"67d15a4e9ebd5f81","repo":"microsoft/autogen","slug":"invalid-message-as-message-from-other","errorCode":null,"errorMessage":"Invalid Message as message from other.","messagePattern":"Invalid Message as message from other\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/AutoGen.OpenAI.V1/Middleware/OpenAIChatRequestMessageConnector.cs","lineNumber":265,"sourceCode":"        {\n            return [new ChatRequestSystemMessage(message.Content) { Name = message.From }];\n        }\n        else if (message.Content is string content && content is { Length: > 0 })\n        {\n            if (message.FunctionName is not null)\n            {\n                return new[] { new ChatRequestToolMessage(content, message.FunctionName) };\n            }\n\n            return [new ChatRequestUserMessage(message.Content) { Name = message.From }];\n        }\n        else if (message.FunctionName is string _)\n        {\n            return [new ChatRequestUserMessage(\"// Message type is not supported\") { Name = message.From }];\n        }\n        else\n        {\n            throw new InvalidOperationException(\"Invalid Message as message from other.\");\n        }\n    }\n\n    private IEnumerable<ChatRequestMessage> ProcessTextMessage(IAgent agent, TextMessage message)\n    {\n        if (message.Role == Role.System)\n        {\n            return [new ChatRequestSystemMessage(message.Content) { Name = message.From }];\n        }\n\n        if (agent.Name == message.From)\n        {\n            return [new ChatRequestAssistantMessage(message.Content) { Name = agent.Name }];\n        }\n        else\n        {\n            return message.From switch\n            {","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.OpenAI.V1/Middleware/OpenAIChatRequestMessageConnector.cs#L247-L283","documentation":"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.","triggerScenarios":"A legacy Message with From != agent.Name, Content null or empty string, and FunctionName null, passed through ProcessIncomingMessages.","commonSituations":"Replaying old conversation logs that contain empty filler messages; upstream agent emitting an empty legacy Message on error; migration from the deprecated Message API.","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"],"exampleFix":"// before\nmessages.Add(new Message(Role.User, content: null, from: \"User\")); // throws\n\n// after\nmessages.Add(new Message(Role.User, content: \"(empty turn)\", from: \"User\"));\n// or better: new TextMessage(Role.User, \"(empty turn)\", from: \"User\")","handlingStrategy":"validation","validationCode":"if (msg is Message { Content: null or \"\" , FunctionName: null }) { /* skip or give placeholder content */ }","typeGuard":null,"tryCatchPattern":"catch (InvalidOperationException ex) when (ex.Message == \"Invalid Message as message from other.\") { /* filter empty legacy messages from history */ }","preventionTips":["Filter empty messages when loading conversation logs","Migrate to TextMessage","Ensure upstream agents never emit empty legacy Messages"],"tags":["autogen","dotnet","azure-openai","legacy-message","empty-message"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}