Add handoff agent-workflow builder (implements #520)#545
Draft
PratikDhanave wants to merge 1 commit into
Draft
Conversation
…uilder) Implements the handoff orchestration gap tracked in microsoft#520. A handoff workflow is a group chat whose next speaker is chosen by the current agent itself: each agent is given a handoff tool for every target it may hand off to, and calling that tool routes the shared conversation to the target. The first agent is the entry agent; a turn with no handoff call ends the workflow. Reuses the existing group chat host executor and GroupChatManager plumbing rather than introducing a new engine: NewHandoffWorkflowBuilder injects per-agent handoff tools and supplies a handoff-flavored manager whose SelectNextAgent routes on the most recent handoff tool call in the previous speaker's turn. Adds a RunOptions field to the hosting Config so the builder can inject those tools into each hosted agent's run. Mirrors the existing builders' API (WithName/WithDescription/WithHandoff/ WithOutputFrom/Build) and the round-robin manager's checkpoint pattern. Covers routing, hand-back, no-handoff termination, builder validation, and manager checkpoint restore. Updates the .NET/Go feature comparison. Implements microsoft#520
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.
Implements the handoff orchestration gap from #520. Opening as a draft to align on the API/mechanism before finalizing — happy to adjust to the team's steer (the design questions in #520 are resolved here with sensible defaults, noted below).
What
A first-class handoff builder alongside the existing sequential / concurrent / group-chat builders:
A handoff workflow is a group chat whose next speaker is chosen by the current agent: each agent is given a
handoff_to_<target>tool for every target it may hand off to; calling that tool routes the shared conversation to the target. The first agent is the entry agent; a turn with no handoff call ends the workflow.How (reuse, not a new engine)
NewHandoffWorkflowBuilderinjects per-agent handoff tools and supplies a handoff-flavoredGroupChatManagerwhoseSelectNextAgentroutes on the most recent handoff tool call in the previous speaker's turn (a cursor tracks per-turn scanning and is checkpoint-persisted, mirroring the round-robin manager'sNextIndex).groupChatHostExecutor, edges, output designations, andprefixingWorkflowContextcheckpoint plumbing.agentworkflow.Config: aRunOptions []agent.Optionfield so the builder can inject the handoff tools into each hosted agent's run (hosting.go). No existing signatures change.Design decisions (the open questions from #520)
.NET-faithful auto-injectedhandoff_to_<target>function tools. Because they carry a handler they auto-execute, so the (resolved) call flows into history for the manager to read — noInterceptUnterminatedFunctionCallsneeded.GroupChatManagervariant; no duplicate engine.WithHandoff(billing, triage)).Tests
handoff_test.go(white-box, matching this package's convention) covers: routing on a handoff call, hand-back (triage→billing→triage), no-handoff termination, builder validation (nil/non-participant agents & targets), and handoff-manager checkpoint restore. All green under-race -shuffle=on; full suite passes. Updatesdocs/dotnet-go-sdk-feature-comparison.md.Open for steer
Naming (
WithHandoffvs edge-style), whether handoff instructions should be auto-added to agent system prompts (.NETdoes), and whether to add anexamples/03-workflowssample once the API is agreed — I'll follow up per the team's preference.