.NET: fix fan-in barrier checkpoint state#6491
Open
he-yufeng wants to merge 1 commit into
Open
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.
Adds coverage and runtime support for preserving fan-in barrier buffered edge state across checkpoint/resume in the in-process workflow runner.
Changes:
- Added a new unit test that checkpoints with a partially satisfied fan-in barrier and verifies buffered contributions are released after resume.
- Exposed edge-state export/import on
InProcessRunnerContext. - Updated
InProcessRunnerto useRunContextfor edge-state serialization during checkpoint/restore.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/CheckpointResumeTests.cs | Adds a regression test and local executors/events to validate fan-in barrier buffering across resume. |
| dotnet/src/Microsoft.Agents.AI.Workflows/InProc/InProcessRunnerContext.cs | Adds context-level methods to export/import edge state with checkpoint lifecycle checks. |
| dotnet/src/Microsoft.Agents.AI.Workflows/InProc/InProcessRunner.cs | Routes checkpoint/restore edge-state handling through RunContext instead of a runner-owned EdgeMap. |
| Workflow workflow = new WorkflowBuilder(beforePause) | ||
| .AddEdge(beforePause, requestPort) | ||
| .AddEdge(requestPort, afterResume) | ||
| .AddFanInBarrierEdge([beforePause, afterResume], sink) |
Comment on lines
+585
to
+586
| private ValueTask HandleAsync(ApprovalReply reply, IWorkflowContext ctx) | ||
| => ctx.SendMessageAsync(new BarrierContribution("after"), sinkId); |
Comment on lines
+414
to
+426
| internal ValueTask<Dictionary<EdgeId, PortableValue>> ExportEdgeStateAsync() | ||
| { | ||
| this.CheckEnded(); | ||
|
|
||
| return this._edgeMap.ExportStateAsync(); | ||
| } | ||
|
|
||
| internal ValueTask ImportEdgeStateAsync(Checkpoint checkpoint) | ||
| { | ||
| this.CheckEnded(); | ||
|
|
||
| return this._edgeMap.ImportStateAsync(checkpoint); | ||
| } |
4ed6147 to
b0bbb9f
Compare
Contributor
Author
|
Rebased onto current Validated locally on Windows with the focused checkpoint regression: Both target frameworks passed the focused test (2 theory cases each). |
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.
Summary
Fixes #6372.
The in-process runner was checkpointing a runner-owned
EdgeMap, while message delivery and fan-in buffering actually use theEdgeMapowned byInProcessRunnerContext. That meant a checkpoint taken after one side of a fan-in barrier had arrived could persist an empty edge state, then lose the buffered message on resume.This changes checkpoint export/import to go through the live runner context edge map and adds a regression test that pauses with one fan-in input buffered, resumes, replies to the pending request, and verifies the barrier releases both pre-checkpoint and post-resume contributions.
Validation
git diff --checkdotnet run --project .\tests\Microsoft.Agents.AI.Workflows.UnitTests\Microsoft.Agents.AI.Workflows.UnitTests.csproj -f net10.0 -- --filter-method Microsoft.Agents.AI.Workflows.UnitTests.CheckpointResumeTests.Checkpoint_Resume_PreservesFanInBarrierBufferedMessagesAsync --no-progressdotnet run --project .\tests\Microsoft.Agents.AI.Workflows.UnitTests\Microsoft.Agents.AI.Workflows.UnitTests.csproj -f net10.0 -- --filter-class Microsoft.Agents.AI.Workflows.UnitTests.CheckpointResumeTests --no-progressdotnet build .\tests\Microsoft.Agents.AI.Workflows.UnitTests\Microsoft.Agents.AI.Workflows.UnitTests.csproj --no-restore --tl:offdotnet format .\src\Microsoft.Agents.AI.Workflows\Microsoft.Agents.AI.Workflows.csproj --verify-no-changes --no-restore --verbosity minimaldotnet format .\tests\Microsoft.Agents.AI.Workflows.UnitTests\Microsoft.Agents.AI.Workflows.UnitTests.csproj --verify-no-changes --no-restore --verbosity minimal