fix: make handoff filtering explicit

Explicitly configure handoff workflows to use
HandoffToolCallFilteringBehavior.HandoffOnly instead of relying on
Agent Framework's current default.

This keeps normal tool-call history visible across handoffs while
still stripping handoff plumbing, and adds a regression test to pin
that behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
David Kaya
2026-04-01 19:04:23 +02:00
co-authored by Copilot
parent 0aed6240b9
commit d7004ec2a9
2 changed files with 70 additions and 2 deletions
@@ -222,8 +222,7 @@ internal sealed class CopilotAgentBundle : IAsyncDisposable
: pattern.Agents.FirstOrDefault()?.Id ?? topology.EntryAgentId;
AIAgent entryAgent = agentMap.GetValueOrDefault(entryAgentId) ?? Agents[0];
HandoffsWorkflowBuilder builder = AgentWorkflowBuilder.CreateHandoffBuilderWith(entryAgent)
.WithHandoffInstructions(HandoffWorkflowGuidance.CreateWorkflowInstructions());
HandoffsWorkflowBuilder builder = CreateHandoffWorkflowBuilder(entryAgent);
foreach (PatternHandoffRoute route in topology.Routes)
{
@@ -250,6 +249,16 @@ internal sealed class CopilotAgentBundle : IAsyncDisposable
return builder.Build();
}
internal static HandoffsWorkflowBuilder CreateHandoffWorkflowBuilder(AIAgent entryAgent)
{
return AgentWorkflowBuilder.CreateHandoffBuilderWith(entryAgent)
// Preserve normal tool-call history across handoffs while still hiding the
// workflow's handoff plumbing. Make this explicit so AF default changes
// cannot silently alter Aryx handoff behavior.
.WithToolCallFilteringBehavior(HandoffToolCallFilteringBehavior.HandoffOnly)
.WithHandoffInstructions(HandoffWorkflowGuidance.CreateWorkflowInstructions());
}
private Workflow BuildGroupChatWorkflow(PatternDefinitionDto pattern)
{
int maximumIterations = pattern.MaxIterations <= 0 ? 5 : pattern.MaxIterations;