Skip to content

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

Merged
lokitoth merged 7 commits intomainfrom
dev/dotnet_workflow/Fix-HandoffChainBreaksDueToToolMessages
Feb 19, 2026
Merged

.NET: Remove FunctionCalls and Tool Messages from Handoff passed messages#3811
lokitoth merged 7 commits intomainfrom
dev/dotnet_workflow/Fix-HandoffChainBreaksDueToToolMessages

Conversation

@lokitoth
Copy link
Member

@lokitoth lokitoth commented Feb 10, 2026

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-microsoft markwallace-microsoft added .NET workflows Related to Workflows in agent-framework labels Feb 10, 2026
@github-actions github-actions bot changed the title Remove FunctionCalls and Tool Messages from Handoff passed messages .NET: Remove FunctionCalls and Tool Messages from Handoff passed messages Feb 10, 2026
@lokitoth lokitoth moved this to In Progress in Agent Framework Feb 10, 2026
@lokitoth lokitoth marked this pull request as ready for review February 10, 2026 14:55
Copilot AI review requested due to automatic review settings February 10, 2026 14:55
@lokitoth lokitoth moved this from In Progress to In Review in Agent Framework Feb 10, 2026
Copy link
Contributor

Copilot AI left a comment

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.

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

@lokitoth lokitoth force-pushed the dev/dotnet_workflow/Fix-HandoffChainBreaksDueToToolMessages branch from 90fda90 to a8e72b7 Compare February 10, 2026 16:00
@lokitoth lokitoth force-pushed the dev/dotnet_workflow/Fix-HandoffChainBreaksDueToToolMessages branch from a8e72b7 to 892fd4a Compare February 10, 2026 16:15
@lokitoth lokitoth force-pushed the dev/dotnet_workflow/Fix-HandoffChainBreaksDueToToolMessages branch from 892fd4a to 7b9b34c Compare February 10, 2026 18:50
@lokitoth lokitoth force-pushed the dev/dotnet_workflow/Fix-HandoffChainBreaksDueToToolMessages branch from 7b9b34c to dc49414 Compare February 11, 2026 15:10
@lokitoth lokitoth force-pushed the dev/dotnet_workflow/Fix-HandoffChainBreaksDueToToolMessages branch from dc49414 to c9b5045 Compare February 11, 2026 15:33
@lokitoth lokitoth force-pushed the dev/dotnet_workflow/Fix-HandoffChainBreaksDueToToolMessages branch from 45175db to 63510bd Compare February 19, 2026 19:13
…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
@lokitoth lokitoth force-pushed the dev/dotnet_workflow/Fix-HandoffChainBreaksDueToToolMessages branch from 63510bd to 02e5d80 Compare February 19, 2026 19:34
@lokitoth lokitoth enabled auto-merge February 19, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET workflows Related to Workflows in agent-framework

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