.NET: fix: Add session support for Handoff-hosted Agents#5280
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates the .NET handoff orchestration to use shared state + bookmarking and to keep a single AgentSession per workflow session, improving checkpointing behavior and ensuring only new messages are sent to underlying agents.
Changes:
- Move handoff message accumulation into shared orchestration state (
HandoffSharedState+MultiPartyConversation). - Add bookmarking support so each agent processes only new messages per invocation.
- Introduce message filtering extraction and expand/adjust unit tests for handoff orchestration behavior.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/TestRunContext.cs | Adds a StateManager to test contexts and wires state operations to it. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/SampleSmokeTest.cs | Updates Step12 expected-output computation to reflect bookmarking/session behavior. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/Sample/12_HandOff_HostAsAgent.cs | Minor formatting adjustment in the Step12 sample. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/HandoffAgentExecutorTests.cs | Initializes shared state for tests and adds a new HITL/subworkflow composition test. |
| dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/MultiPartyConversation.cs | New shared conversation buffer with bookmarking support. |
| dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/HandoffState.cs | Removes per-message payload from HandoffState (messages now live in shared state). |
| dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/HandoffStartExecutor.cs | Initializes/updates shared orchestration state and emits bookmark-driven HandoffState. |
| dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/HandoffMessagesFilter.cs | Extracts tool-call filtering logic into a dedicated type. |
| dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/HandoffEndExecutor.cs | Reads from shared state and yields the accumulated conversation at workflow end. |
| dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/HandoffAgentExecutor.cs | Adds agent-session use, bookmarking, and shared-state persistence for conversation messages. |
| dotnet/src/Microsoft.Agents.AI.Workflows/AIAgentsAbstractionsExtensions.cs | Broadens role-changing helper to accept IEnumerable<ChatMessage>. |
eefa1af to
8e28117
Compare
8e28117 to
068f4b3
Compare
b6f0458 to
f69b9b2
Compare
1801d89 to
f684fde
Compare
In order to better support using `Workflows` hosted as `AIAgents` inside of Handoff workflows, we need to make proper use of AgentSession. This causes potential issues around checkpointing and making sure that we properly compute only the new incoming messages for each agent invocation.
… methods We cannot rely on implicit serialization through `HandoffHostState` because we are missing type information.
…was wrapped into FunctionCallContent
f684fde to
70d5aca
Compare
lokitoth
commented
Apr 16, 2026
westey-m
approved these changes
Apr 17, 2026
peibekwe
approved these changes
Apr 17, 2026
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.
Motivation and Context
In order to better support using
Workflowshosted asAIAgentsinside of Handoff workflows, we need to make proper use of AgentSession. This causes potential issues around checkpointing and making sure that we properly compute only the new incoming messages for each agent invocation.Description
HandoffAgentExecutorto properly subselect only new messages when invoking the underlying agentContribution Checklist
[ ] Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.