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 1c4ceee
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?")]);
308
+
309
+
Assert.NotNull(capturedNextAgentMessages);
310
+
311
+
// The target agent should see the original user message
312
+
Assert.Contains(capturedNextAgentMessages, m =>m.Role==ChatRole.User&&m.Text=="What is the derivative of x^2?");
313
+
314
+
// The target agent should NOT see the handoff function call or tool result from the source agent
315
+
Assert.DoesNotContain(capturedNextAgentMessages, m =>m.Contents.Any(c =>cisFunctionCallContentfcc&&fcc.Name.StartsWith("handoff_to_",StringComparison.Ordinal)));
316
+
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
369
+
Assert.NotNull(capturedSecondAgentMessages);
370
+
Assert.Contains(capturedSecondAgentMessages, m =>m.Text=="abc");
371
+
Assert.Contains(capturedSecondAgentMessages, m =>m.Text!.Contains("Routing to second agent"));
372
+
Assert.DoesNotContain(capturedSecondAgentMessages, m =>m.Contents.Any(c =>cisFunctionCallContentfcc&&fcc.Name.StartsWith("handoff_to_",StringComparison.Ordinal)));
373
+
Assert.DoesNotContain(capturedSecondAgentMessages, m =>m.Role==ChatRole.Tool&&m.Contents.Any(c =>cisFunctionResultContent));
374
+
375
+
// Third agent should see the original user message and both prior agents' text as context
376
+
Assert.NotNull(capturedThirdAgentMessages);
377
+
Assert.Contains(capturedThirdAgentMessages, m =>m.Text=="abc");
378
+
Assert.Contains(capturedThirdAgentMessages, m =>m.Text!.Contains("Routing to second agent"));
379
+
Assert.Contains(capturedThirdAgentMessages, m =>m.Text!.Contains("Routing to third agent"));
380
+
Assert.DoesNotContain(capturedThirdAgentMessages, m =>m.Contents.Any(c =>cisFunctionCallContentfcc&&fcc.Name.StartsWith("handoff_to_",StringComparison.Ordinal)));
381
+
Assert.DoesNotContain(capturedThirdAgentMessages, m =>m.Role==ChatRole.Tool&&m.Contents.Any(c =>cisFunctionResultContent));
0 commit comments