Repository navigation
.NET: fix(dotnet): reset compiled workflow state between runs - #9540
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 12f29503-c7ae-410b-a598-d0ba4e8e937b
There was a problem hiding this comment.
🟡 Changes recommended
Checkpoint restoration and mutable snapshot isolation remain unresolved.
2 open issues
What changed in this PR
Updates compiled declarative workflows to reset formula state between runs and resolve conversations consistently with the interpreter.
Changes:
- Captures initialized state and restores it on reset.
- Resolves conversations from current state before configured or newly created conversations.
- Adds reset and conversation-reuse regression tests.
| File | Description |
|---|---|
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Kit/RootExecutorTests.cs | Adds state-reset and conversation lifecycle tests. |
| dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Kit/RootExecutor.cs | Implements state reset and per-run conversation resolution. |
Review effort: Balanced
Code coverage overviewLanguages: C# C# / code-coverage/dotnet
View coverage of the 6 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): 642b85e46e8f
Model: gpt-5.6-sol
Overview
The PR captures initialized formula state, restores it when a workflow releases ownership, and resolves conversations from current run state before falling back to configuration or allocation. The reset lifecycle and added tests provide strong coverage for scalar values, sensitivities, configured conversations, and within-run reuse. Residual risks remain around checkpoint restoration, unreclaimed per-run backend conversations, and failed persistence immediately after conversation creation.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
3 verified findings remained after source verification (2 high, 1 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Kit/RootExecutor.cs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 12f29503-c7ae-410b-a598-d0ba4e8e937b
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 12f29503-c7ae-410b-a598-d0ba4e8e937b
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 12f29503-c7ae-410b-a598-d0ba4e8e937b
There was a problem hiding this comment.
MAF Automated Review — Iteration 2
Result: Findings reported
Scope: 3 net-new commit(s): 9cbb89b49952, f9ed58b4242d, 5c63547718f3
Model: gpt-5.6-sol
Overview
The change adds initial-state reset, checkpoint restoration, current-allowlist filtering for environment values, and per-run conversation reuse, with focused tests for each behavior. Copying the conversation record and caching a newly allocated ID provide concrete guards against snapshot aliasing and retry leaks. However, checkpoint state is stored per executor while the shared formula session admits only one nondeterministic restore callback, and existing subclasses can bypass the new restoration by overriding the previously no-op lifecycle hook.
Reviewed the supplied incremental change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (1 high, 1 medium) across 2 files. Details are attached to the affected lines below.
Affected areas: dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Kit/ActionExecutor.cs, dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Kit/RootExecutor.cs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 12f29503-c7ae-410b-a598-d0ba4e8e937b
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 12f29503-c7ae-410b-a598-d0ba4e8e937b


Motivation & Context
Compiled declarative workflows should restore their initial formula state when reset and resolve their backend conversation consistently with the declarative interpreter.
Description & Review Guide
Executor.RegisterCheckpointRestoringCallbackoverloads are recorded in every target framework's API baseline; existing virtual hook signatures and subclass overrides remain unchanged.Container validation with .NET SDK 10.0.402, from
dotnet:dotnet run --project tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests -f net10.0 --no-build --no-restore -- --filter-class '*RootExecutorTests': before the initial fix, 5 failed and 2 passed; afterward, all 8 passed.dotnet run --project tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests -f net10.0 --no-restore -- --filter-class '*RootExecutorTests': checkpoint/reset, retry, environment, and subclass-hook regressions failed before their respective fixes. The live-restore follow-up reproduced two failures before its fix (18 passed); all 20 focused cases passed afterward. The action-writer/reader cases with base chaining already passed before the subclass-hook follow-up.dotnet run --project tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests -f net10.0 --no-restore: all 1,159 passed, including current-allowlist filtering, cross-action values, and live restoration of values, metadata, conversation state, and expression results.dotnet run --project tests/Microsoft.Agents.AI.Workflows.UnitTests -f net10.0 --no-restore -- --filter-class '*CheckpointResumeTests': all 27 passed, including asynchronous restoration barriers and once-per-load shared callbacks in off-thread and lockstep execution.dotnet run --project tests/Microsoft.Agents.AI.Workflows.UnitTests -f net10.0 --no-restore: all 865 passed.dotnet format src/Microsoft.Agents.AI.Workflows --no-restore --include /repo/dotnet/src/Microsoft.Agents.AI.Workflows/Executor.cs /repo/dotnet/src/Microsoft.Agents.AI.Workflows/InProc/InProcessRunnerContext.cs: passed.dotnet format src/Microsoft.Agents.AI.Workflows.Declarative --no-restore --include /repo/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Kit/RootExecutor.cs /repo/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Kit/ActionExecutor.cs /repo/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/PowerFx/WorkflowFormulaState.cs: passed.dotnet format tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests --no-restore --include /repo/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Kit/RootExecutorTests.cs: passed.dotnet format tests/Microsoft.Agents.AI.Workflows.UnitTests --no-restore --include /repo/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/CheckpointResumeTests.cs: passed.dotnet build src/Microsoft.Agents.AI.Workflows.Declarative --no-restore --tl:off: passed for net10.0, net9.0, net8.0, netstandard2.0, and net472, with 40 container SourceLink/repository-location warnings.Packages were restored from an existing local cache because the container could not connect to NuGet. Online package auditing and the full repository test suite were not run locally.
Related Issue
N/A - maintainer-directed bugfix; no public issue linked. Open pull requests were checked for competing changes.
AI Assistance
AI assistance details: Implementation, regression tests, validation, and this PR description.
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.