{"record":{"id":"3a59aa64256f4f5f","repo":"microsoft/autogen","slug":"function-call-is-not-supported-in-the-semantic-ker","errorCode":null,"errorMessage":"Function call is not supported in the semantic kernel if it's from self.","messagePattern":"Function call is not supported in the semantic kernel if it's from self\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/AutoGen.SemanticKernel/Middleware/SemanticKernelChatMessageContentConnector.cs","lineNumber":239,"sourceCode":"            }\n        }\n        return [new ChatMessageContent(AuthorRole.User, collections)];\n    }\n\n    [Obsolete(\"This method is deprecated, please use the specific method instead.\")]\n    private IEnumerable<ChatMessageContent> ProcessMessageForSelf(Message message)\n    {\n        if (message.Role == Role.System)\n        {\n            return [new ChatMessageContent(AuthorRole.System, message.Content)];\n        }\n        else if (message.Content is string && message.FunctionName is null && message.FunctionArguments is null)\n        {\n            return [new ChatMessageContent(AuthorRole.Assistant, message.Content)];\n        }\n        else if (message.Content is null && message.FunctionName is not null && message.FunctionArguments is not null)\n        {\n            throw new System.InvalidOperationException(\"Function call is not supported in the semantic kernel if it's from self.\");\n        }\n        else\n        {\n            throw new System.InvalidOperationException(\"Unsupported message type\");\n        }\n    }\n\n    [Obsolete(\"This method is deprecated, please use the specific method instead.\")]\n    private IEnumerable<ChatMessageContent> ProcessMessageForOthers(Message message)\n    {\n        if (message.Role == Role.System)\n        {\n            return [new ChatMessageContent(AuthorRole.System, message.Content)];\n        }\n        else if (message.Content is string && message.FunctionName is null && message.FunctionArguments is null)\n        {\n            return [new ChatMessageContent(AuthorRole.User, message.Content)];\n        }","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.SemanticKernel/Middleware/SemanticKernelChatMessageContentConnector.cs#L221-L257","documentation":"The deprecated-Message handler for self-authored messages only supports plain text. A legacy Message with null Content but non-null FunctionName/FunctionArguments (i.e. a function call from the agent itself) cannot be represented in SK chat content and throws InvalidOperationException.","triggerScenarios":"Replaying a legacy Message representing a self function call (Content == null, FunctionName != null, FunctionArguments != null) to the same SK agent.","commonSituations":"Migrating old AutoGen conversations built on the obsolete Message type; replaying stored logs that captured function-call turns as Message objects.","solutions":["Migrate from the obsolete Message type to ToolCallMessage/ToolCallResultMessage and use a connector that supports tool calls.","Convert legacy function-call Messages into a textual summary TextMessage before replay to an SK agent.","Filter self function-call Messages out of the history sent to SK agents."],"exampleFix":"// before (legacy)\nvar legacy = new Message(Role.Assistant, null, functionName: \"get_weather\", functionArguments: \"{\\\"city\\\":\\\"sf\\\"}\", from: skAgent.Name);\nawait skAgent.SendAsync(new[] { legacy });\n\n// after\nvar summary = new TextMessage(Role.Assistant, \"Called get_weather({\\\"city\\\":\\\"sf\\\"})\", from: skAgent.Name);\nawait skAgent.SendAsync(new[] { summary });","handlingStrategy":"fallback","validationCode":"// Convert legacy function-call Messages to text summaries before replay\nvar replayable = history.Select(m => m is Message msg && msg.FunctionName is not null && msg.Content is null\n    ? new TextMessage(Role.Assistant, $\"Called {msg.FunctionName}({msg.FunctionArguments})\", from: msg.From)\n    : (IMessage)m);","typeGuard":"static bool IsLegacySelfFunctionCall(IMessage m, string agentName) =>\n    m is Message msg && msg.From == agentName && msg.Content is null && msg.FunctionName is not null;","tryCatchPattern":"catch (InvalidOperationException ex) when (ex.Message.Contains(\"Function call is not supported\"))\n{\n    logger.LogWarning(\"Dropping legacy self function-call message\");\n    return await skAgent.SendAsync(history.Where(m => !IsLegacySelfFunctionCall(m, skAgent.Name)));\n}","preventionTips":["Migrate persistence layers off the obsolete Message type to ToolCallMessage/ToolCallResultMessage.","Treat legacy logs as needing normalization before replay into SK agents."],"tags":["semantic-kernel","legacy-message","function-calls","autogen","csharp"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}