You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit da7e63d
Browse filesBrowse the repository at this point in the historyBrowse files
Jacob Alber
committed
Fix handoff orchestration not passing user message to handoff target agent (#3161)
Filter out internal handoff function call and tool result messages before
passing conversation history to the target agent's LLM. These messages
confused the model into ignoring the original user question.
_=awaitRunWorkflowAsync(workflow,[newChatMessage(ChatRole.User,"What is the derivative of x^2?")]);
309
+
310
+
Assert.NotNull(capturedNextAgentMessages);
311
+
312
+
// The target agent should see the original user message
313
+
Assert.Contains(capturedNextAgentMessages, m =>m.Role==ChatRole.User&&m.Text=="What is the derivative of x^2?");
314
+
315
+
// The target agent should NOT see the handoff function call or tool result from the source agent
316
+
Assert.DoesNotContain(capturedNextAgentMessages, m =>m.Contents.Any(c =>cisFunctionCallContentfcc&&fcc.Name.StartsWith("handoff_to_",StringComparison.Ordinal)));
317
+
Assert.DoesNotContain(capturedNextAgentMessages, m =>m.Role==ChatRole.Tool&&m.Contents.Any(c =>cisFunctionResultContentfrc&&frc.Result?.ToString()=="Transferred."));
// Second agent should see the original user message and initialAgent's text as context
370
+
Assert.NotNull(capturedSecondAgentMessages);
371
+
Assert.Contains(capturedSecondAgentMessages, m =>m.Text=="abc");
372
+
Assert.Contains(capturedSecondAgentMessages, m =>m.Text!.Contains("Routing to second agent"));
373
+
Assert.DoesNotContain(capturedSecondAgentMessages, m =>m.Contents.Any(c =>cisFunctionCallContentfcc&&fcc.Name.StartsWith("handoff_to_",StringComparison.Ordinal)));
374
+
Assert.DoesNotContain(capturedSecondAgentMessages, m =>m.Role==ChatRole.Tool&&m.Contents.Any(c =>cisFunctionResultContent));
375
+
376
+
// Third agent should see the original user message and both prior agents' text as context
377
+
Assert.NotNull(capturedThirdAgentMessages);
378
+
Assert.Contains(capturedThirdAgentMessages, m =>m.Text=="abc");
379
+
Assert.Contains(capturedThirdAgentMessages, m =>m.Text!.Contains("Routing to second agent"));
380
+
Assert.Contains(capturedThirdAgentMessages, m =>m.Text!.Contains("Routing to third agent"));
381
+
Assert.DoesNotContain(capturedThirdAgentMessages, m =>m.Contents.Any(c =>cisFunctionCallContentfcc&&fcc.Name.StartsWith("handoff_to_",StringComparison.Ordinal)));
382
+
Assert.DoesNotContain(capturedThirdAgentMessages, m =>m.Role==ChatRole.Tool&&m.Contents.Any(c =>cisFunctionResultContent));
0 commit comments