Skip to content

.NET: Remove FunctionCalls and Tool Messages from Handoff passed messages - #3811

Merged
Jacob Alber (lokitoth) merged 7 commits into
mainfrom
dev/dotnet_workflow/Fix-HandoffChainBreaksDueToToolMessages
Feb 19, 2026
Merged

.NET: Remove FunctionCalls and Tool Messages from Handoff passed messages#3811
Jacob Alber (lokitoth) merged 7 commits into
mainfrom
dev/dotnet_workflow/Fix-HandoffChainBreaksDueToToolMessages

Conversation

@lokitoth

@lokitothJacob Alber (lokitoth) commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

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

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@markwallace-microsoftMark Wallace (markwallace-microsoft) added .NET Usage: [Issues, PRs], Target: .Net workflows Usage: [Issues, PRs], Target: Workflows labels Feb 10, 2026
@github-actionsgithub-actionsBot changed the title Remove FunctionCalls and Tool Messages from Handoff passed messages.NET: Remove FunctionCalls and Tool Messages from Handoff passed messagesFeb 10, 2026
@lokitoth
Jacob Alber (lokitoth) marked this pull request as ready for review February 10, 2026 14:55
CopilotAI review requested due to automatic review settings February 10, 2026 14:55
@lokitothJacob Alber (lokitoth) moved this from In Progress to In Review in Agent FrameworkFeb 10, 2026

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

FileDescription
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/AgentWorkflowBuilderTests.csAdded 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.csAdded FilterHandoffMessages method to filter out handoff function calls and tool results; integrated filtering logic into the handoff message flow

@lokitoth
Jacob Alber (lokitoth)force-pushed the dev/dotnet_workflow/Fix-HandoffChainBreaksDueToToolMessages branch from 7b9b34c to dc49414CompareFebruary 11, 2026 15:10
@lokitoth
Jacob Alber (lokitoth)force-pushed the dev/dotnet_workflow/Fix-HandoffChainBreaksDueToToolMessages branch from dc49414 to c9b5045CompareFebruary 11, 2026 15:33
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NETUsage: [Issues, PRs], Target: .NetworkflowsUsage: [Issues, PRs], Target: Workflows

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

.NET: [Bug]: Handoff orchestration does not pass message to the handoff agent

5 participants

@lokitoth@SergeyMenshykh@markwallace-microsoft@westey-m