microsoft/autogen · error · ArgumentException
ToolCallMessage is not supported when message.From is not th
Error message
ToolCallMessage is not supported when message.From is not the same with agent
What it means
Error "ToolCallMessage is not supported when message.From is not the same with agent" thrown in microsoft/autogen.
Source
Thrown at dotnet/src/AutoGen.AzureAIInference/Middleware/AzureAIInferenceChatRequestMessageConnector.cs:261
ImageMessage image => this.CreateChatMessageImageContentItemFromImageMessage(image),
_ => throw new NotImplementedException(),
});
return [new ChatRequestUserMessage(items)];
}
private ChatMessageImageContentItem CreateChatMessageImageContentItemFromImageMessage(ImageMessage message)
{
return message.Data is null && message.Url is not null
? new ChatMessageImageContentItem(new Uri(message.Url))
: new ChatMessageImageContentItem(message.Data, message.Data?.MediaType);
}
private IEnumerable<ChatRequestMessage> ProcessToolCallMessage(IAgent agent, ToolCallMessage message)
{
if (message.From is not null && message.From != agent.Name)
{
throw new ArgumentException("ToolCallMessage is not supported when message.From is not the same with agent");
}
var toolCall = message.ToolCalls.Select((tc, i) => new ChatCompletionsFunctionToolCall(tc.ToolCallId ?? $"{tc.FunctionName}_{i}", tc.FunctionName, tc.FunctionArguments));
var textContent = message.GetContent() ?? string.Empty;
var chatRequestMessage = new ChatRequestAssistantMessage() { Content = textContent };
foreach (var tc in toolCall)
{
chatRequestMessage.ToolCalls.Add(tc);
}
return [chatRequestMessage];
}
private IEnumerable<ChatRequestMessage> ProcessToolCallResultMessage(ToolCallResultMessage message)
{
return message.ToolCalls
.Where(tc => tc.Result is not null)
.Select((tc, i) => new ChatRequestToolMessage(tc.Result, tc.ToolCallId ?? $"{tc.FunctionName}_{i}"));View on GitHub (pinned to 027ecf0a37)
Solutions
- Tool calls must originate from this agent's own replies
Example fix
Filter out foreign ToolCallMessages or convert them to text
When it happens
Trigger: Thrown at dotnet/src/AutoGen.AzureAIInference/Middleware/AzureAIInferenceChatRequestMessageConnector.cs:261 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/9f620471a9cb0ecd.
Report an issue: GitHub.