.NET: Validate handoff request lifecycle before routing - #8855
Roger Barreto (rogerbarreto) wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The lifecycle logic is consistent with the routing model and is covered by focused regression tests.
Review effort: Balanced
Findings: None
What changed in this PR
Validates handoff request lifecycle before routing and prevents completed or ineligible tool calls from triggering handoffs.
Changes:
- Tracks unresolved handoff calls by stream order, identity, role, declaration, and call ID.
- Adds regression coverage for completion matching, provenance, eligibility, and cancellation isolation.
- Waits for workflow halt before checkpoint restoration.
| File | Description |
|---|---|
dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/HandoffAgentExecutor.cs |
Validates and tracks routing candidates. |
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/HandoffAgentExecutorTests.cs |
Covers updated lifecycle behavior. |
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/Sample/05_Simple_Workflow_Checkpointing.cs |
Synchronizes restoration with workflow halt. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): 932c4530dfb2
Model: gpt-5.6-sol-fast
Overview
The change makes handoff selection invocation-local, processes completions in stream order, and adds useful coverage for matching completions, unrelated completions, malformed provenance, and cancellation. However, it treats optional streaming metadata as mandatory on each delta, which breaks valid handoffs for supported agents/providers, and it matches completions by a globally unscoped call ID, allowing another producer's result to suppress routing.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (1 high, 1 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/HandoffAgentExecutor.cs
Code Coverage OverviewLanguages: C# C# / code-coverage/dotnetThe overall line coverage in commit faa1caa in the Show a line coverage summary of the most covered files.
Updated |
Motivation & Context
Handoff routing should distinguish unresolved requests from completed tool lifecycle events and preserve the identity of the agent producing each request. This keeps streamed tool updates consistent with workflow routing decisions.
Description & Review Guide
Related Issue
N/A.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.