Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical bug in handoff orchestration where FunctionCall and Tool messages from handoff operations were being passed to target agents, causing the LLM to ignore the original user question. The fix filters out these internal workflow mechanics before sending messages to the target agent.
Changes:
- Added regression tests to verify that handoff function calls and tool results are not passed to target agents
- Added regression tests for multi-hop handoff scenarios to ensure proper message propagation
- Implemented FilterHandoffMessages method to remove handoff-related messages before sending to target agents
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/AgentWorkflowBuilderTests.cs | Added two comprehensive regression tests verifying that handoff targets do not receive handoff function messages in single and multi-hop scenarios |
| dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/HandoffAgentExecutor.cs | Added FilterHandoffMessages method to filter out handoff function calls and tool results; integrated filtering logic into the handoff message flow |
dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/HandoffAgentExecutor.cs
Outdated
Show resolved
Hide resolved
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/AgentWorkflowBuilderTests.cs
Outdated
Show resolved
Hide resolved
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/AgentWorkflowBuilderTests.cs
Outdated
Show resolved
Hide resolved
SergeyMenshykh
approved these changes
Feb 10, 2026
westey-m
reviewed
Feb 10, 2026
dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/HandoffAgentExecutor.cs
Outdated
Show resolved
Hide resolved
westey-m
approved these changes
Feb 10, 2026
90fda90 to
a8e72b7
Compare
a8e72b7 to
892fd4a
Compare
892fd4a to
7b9b34c
Compare
dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/HandoffAgentExecutor.cs
Outdated
Show resolved
Hide resolved
7b9b34c to
dc49414
Compare
dc49414 to
c9b5045
Compare
45175db to
63510bd
Compare
…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.
- Introduced HandoffToolCallFilteringBehavior enum to specify filtering behavior for tool call contents in handoff workflows. - Updated HandoffsWorkflowBuilder to support customizable handoff instructions and tool call filtering behavior. - Enhanced HandoffAgentExecutor to utilize new filtering options for improved message handling during agent handoffs.
…s and enhance filtering logic for non-handoff function calls
…tialization and improve clarity
…egration tests for handoff workflows
63510bd to
02e5d80
Compare
westey-m
approved these changes
Feb 19, 2026
This was referenced Feb 23, 2026
This was referenced Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
The Handoff Orchestration currently does not filter out the HandoffTool FunctionCall messages or the Tool FunctionResult messages. This can cause odd behaviour, such as the LLM ignoring the original user question.
Description
FunctionCallandToolcontent (fixes .NET: [Bug]: Handoff orchestration does not pass message to the handoff agent #3161, .NET: [Workflows] Handoff tool response appears in chat history, causing inconsistent LLM behavior #3046)ChatMessagesbetween agentsContribution Checklist
Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.