{"record":{"id":"70e4668e7d50bc74","repo":"microsoft/autogen","slug":"tool-call-message-from-another-agent-is-not-suppor","errorCode":null,"errorMessage":"Tool call message from another agent is not supported","messagePattern":"Tool call message from another agent is not supported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"dotnet/src/AutoGen.Mistral/Middleware/MistralChatMessageConnector.cs","lineNumber":303,"sourceCode":"\n            return messages.Select(m => new MessageEnvelope<ChatMessage>(m, from: from));\n        }\n\n        // if the message is from the same agent or the from field is empty, then expand the message to tool call message and tool call result message\n        var toolCallMessage = aggregateMessage.Message1;\n        var toolCallResultMessage = aggregateMessage.Message2;\n\n        return this.ProcessToolCallMessage(toolCallMessage, agent).Concat(this.ProcessToolCallResultMessage(toolCallResultMessage, agent));\n    }\n\n    private IEnumerable<IMessage<ChatMessage>> ProcessToolCallMessage(ToolCallMessage toolCallMessage, IAgent agent)\n    {\n        IEnumerable<ChatMessage> messages;\n\n        // the scenario is not support when tool call message is from another agent\n        if (toolCallMessage.From is string from && from != agent.Name)\n        {\n            throw new NotSupportedException(\"Tool call message from another agent is not supported\");\n        }\n\n        // convert tool call message to chat message\n        var chatMessage = new ChatMessage(ChatMessage.RoleEnum.Assistant);\n        chatMessage.ToolCalls = new List<FunctionContent>();\n        for (var i = 0; i < toolCallMessage.ToolCalls.Count; i++)\n        {\n            var toolCall = toolCallMessage.ToolCalls[i];\n            var toolCallId = toolCall.ToolCallId ?? $\"{toolCall.FunctionName}_{i}\";\n            var functionCall = new FunctionContent.FunctionCall(toolCall.FunctionName, toolCall.FunctionArguments);\n            var functionContent = new FunctionContent(toolCallId, functionCall);\n            chatMessage.ToolCalls.Add(functionContent);\n        }\n\n        messages = [chatMessage];\n\n        return messages.Select(m => new MessageEnvelope<ChatMessage>(m, from: toolCallMessage.From));\n    }","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.Mistral/Middleware/MistralChatMessageConnector.cs#L285-L321","documentation":"NotSupportedException raised in ProcessToolCallMessage: a ToolCallMessage whose From names a different agent cannot be replayed into the current Mistral agent. The connector must rewrite tool calls as if the current agent produced them, so third-party tool-call messages are rejected.","triggerScenarios":"Two-agent workflows where agent A produces a ToolCallMessage and that message is forwarded into agent B's chat history (e.g. a group chat or sequential pipeline passing messages verbatim). The check toolCallMessage.From != agent.Name at MistralChatMessageConnector.cs:307 fires.","commonSituations":"Group chat (RoundRobinGroupChat / GroupChat) with function-calling agents; manually assembling histories from multiple agents; middleware that copies messages between agents while preserving From.","solutions":["Strip or rewrite the From field on the ToolCallMessage to the receiving agent's name before sending it.","Route tool-call messages back to the agent that created them; give other agents only ToolCallResultMessage/text summaries.","In group-chat setups, ensure the tool-call executor agent is the one that receives its own tool call output."],"exampleFix":"// before\nvar msgFromA = new ToolCallMessage(calls, from: \"AgentA\");\nawait agentB.SendAsync(msgFromA); // throws\n\n// after\nvar replayable = new ToolCallMessage(calls, from: agentB.Name);\nawait agentB.SendAsync(replayable);","handlingStrategy":"validation","validationCode":"// before forwarding a ToolCallMessage to another agent, rewrite From\nif (toolCallMessage.From is string f && f != targetAgent.Name)\n{\n    toolCallMessage = new ToolCallMessage(toolCallMessage.ToolCalls, from: targetAgent.Name);\n}","typeGuard":"static bool IsReplayableBy(ToolCallMessage m, IAgent agent) =>\n    m.From is null || m.From == agent.Name;","tryCatchPattern":"catch (NotSupportedException ex) when (ex.Message.Contains(\"Tool call message from another agent\"))\n{\n    // route the message back to its origin agent instead\n}","preventionTips":["Design group-chat selectors so tool-call outputs return to their producing agent","Keep From set on all messages when building multi-agent histories"],"tags":["mistral","tool-calls","multi-agent","group-chat"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}