When using a Workflow with tool calls and responses wrapped in .AsAgent(), outgoing messages are topologically sorted and merged using the MessageMerger. This does not behave correctly in the presence of ToolCalls/Responses in Handoff workflows, resulting in unexpected message ordering.
This is somewhat hidden when running using WorkflowHostAgent.RunStreamingAsync() because the outgoing enumeration yields the events in raw order, rather than in merged order. History still uses merged order, and this is directly visible when running using WorkflowHostAgent.RunAsync()
When using a Workflow with tool calls and responses wrapped in
.AsAgent(), outgoing messages are topologically sorted and merged using theMessageMerger. This does not behave correctly in the presence of ToolCalls/Responses in Handoff workflows, resulting in unexpected message ordering.This is somewhat hidden when running using
WorkflowHostAgent.RunStreamingAsync()because the outgoing enumeration yields the events in raw order, rather than in merged order. History still uses merged order, and this is directly visible when running usingWorkflowHostAgent.RunAsync()