{"record":{"id":"d0ac5e9d5e67a028","repo":"microsoft/autogen","slug":"invalid-return-message-type-message-gettype-nam","errorCode":null,"errorMessage":"Invalid return message type {message.GetType().Name}","messagePattern":"Invalid return message type (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/AutoGen.AzureAIInference/Middleware/AzureAIInferenceChatRequestMessageConnector.cs","lineNumber":98,"sourceCode":"                {\n                    throw new InvalidOperationException($\"Invalid streaming message type {reply.GetType().Name}\");\n                }\n                else\n                {\n                    yield return reply;\n                }\n            }\n        }\n    }\n\n    public IMessage PostProcessMessage(IMessage message)\n    {\n        return message switch\n        {\n            IMessage<ChatResponseMessage> m => PostProcessChatResponseMessage(m.Content, m.From),\n            IMessage<ChatCompletions> m => PostProcessChatCompletions(m),\n            _ when strictMode is false => message,\n            _ => throw new InvalidOperationException($\"Invalid return message type {message.GetType().Name}\"),\n        };\n    }\n\n    public IMessage? PostProcessStreamingMessage(IMessage<StreamingChatCompletionsUpdate> update, string? currentToolName)\n    {\n        if (update.Content.ContentUpdate is string contentUpdate && string.IsNullOrEmpty(contentUpdate) == false)\n        {\n            // text message\n            return new TextMessageUpdate(Role.Assistant, contentUpdate, from: update.From);\n        }\n        else if (update.Content.FunctionName is string functionName)\n        {\n            return new ToolCallMessageUpdate(functionName, string.Empty, from: update.From);\n        }\n        else if (update.Content.FunctionArgumentsUpdate is string functionArgumentsUpdate && currentToolName is string)\n        {\n            return new ToolCallMessageUpdate(currentToolName, functionArgumentsUpdate, from: update.From);\n        }","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.AzureAIInference/Middleware/AzureAIInferenceChatRequestMessageConnector.cs#L80-L116","documentation":"Error \"Invalid return message type {message.GetType().Name}\" thrown in microsoft/autogen.","triggerScenarios":"Thrown at dotnet/src/AutoGen.AzureAIInference/Middleware/AzureAIInferenceChatRequestMessageConnector.cs:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Return a TextMessage or ToolCallMessage as the final reply"],"exampleFix":"Ensure the agent's final reply is a supported IMessage type","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}