microsoft/autogen · error · NotSupportedException

Tool call message from another agent is not supported

Error message

Tool call message from another agent is not supported

What it means

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.

Source

Thrown at dotnet/src/AutoGen.Mistral/Middleware/MistralChatMessageConnector.cs:303

            return messages.Select(m => new MessageEnvelope<ChatMessage>(m, from: from));
        }

        // 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
        var toolCallMessage = aggregateMessage.Message1;
        var toolCallResultMessage = aggregateMessage.Message2;

        return this.ProcessToolCallMessage(toolCallMessage, agent).Concat(this.ProcessToolCallResultMessage(toolCallResultMessage, agent));
    }

    private IEnumerable<IMessage<ChatMessage>> ProcessToolCallMessage(ToolCallMessage toolCallMessage, IAgent agent)
    {
        IEnumerable<ChatMessage> messages;

        // the scenario is not support when tool call message is from another agent
        if (toolCallMessage.From is string from && from != agent.Name)
        {
            throw new NotSupportedException("Tool call message from another agent is not supported");
        }

        // convert tool call message to chat message
        var chatMessage = new ChatMessage(ChatMessage.RoleEnum.Assistant);
        chatMessage.ToolCalls = new List<FunctionContent>();
        for (var i = 0; i < toolCallMessage.ToolCalls.Count; i++)
        {
            var toolCall = toolCallMessage.ToolCalls[i];
            var toolCallId = toolCall.ToolCallId ?? $"{toolCall.FunctionName}_{i}";
            var functionCall = new FunctionContent.FunctionCall(toolCall.FunctionName, toolCall.FunctionArguments);
            var functionContent = new FunctionContent(toolCallId, functionCall);
            chatMessage.ToolCalls.Add(functionContent);
        }

        messages = [chatMessage];

        return messages.Select(m => new MessageEnvelope<ChatMessage>(m, from: toolCallMessage.From));
    }

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Strip or rewrite the From field on the ToolCallMessage to the receiving agent's name before sending it.
  2. Route tool-call messages back to the agent that created them; give other agents only ToolCallResultMessage/text summaries.
  3. In group-chat setups, ensure the tool-call executor agent is the one that receives its own tool call output.

Example fix

// before
var msgFromA = new ToolCallMessage(calls, from: "AgentA");
await agentB.SendAsync(msgFromA); // throws

// after
var replayable = new ToolCallMessage(calls, from: agentB.Name);
await agentB.SendAsync(replayable);
Defensive patterns

Strategy: validation

Validate before calling

// before forwarding a ToolCallMessage to another agent, rewrite From
if (toolCallMessage.From is string f && f != targetAgent.Name)
{
    toolCallMessage = new ToolCallMessage(toolCallMessage.ToolCalls, from: targetAgent.Name);
}

Type guard

static bool IsReplayableBy(ToolCallMessage m, IAgent agent) =>
    m.From is null || m.From == agent.Name;

Try / catch

catch (NotSupportedException ex) when (ex.Message.Contains("Tool call message from another agent"))
{
    // route the message back to its origin agent instead
}

Prevention

When it happens

Trigger: 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.

Common situations: Group chat (RoundRobinGroupChat / GroupChat) with function-calling agents; manually assembling histories from multiple agents; middleware that copies messages between agents while preserving From.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/70e4668e7d50bc74. Report an issue: GitHub.