Skip to content

.NET: Fix FileSystemJsonCheckpointStore.RetrieveCheckpointAsync using wrong path in File.Exists#5169

Merged
westey-m merged 1 commit intomicrosoft:mainfrom
westey-m:samples-fixes-2026-04-08
Apr 9, 2026
Merged

.NET: Fix FileSystemJsonCheckpointStore.RetrieveCheckpointAsync using wrong path in File.Exists#5169
westey-m merged 1 commit intomicrosoft:mainfrom
westey-m:samples-fixes-2026-04-08

Conversation

@westey-m
Copy link
Copy Markdown
Contributor

@westey-m westey-m commented Apr 8, 2026

Problem

Three declarative workflow samples (Workflow_Declarative_FunctionTools, Workflow_Declarative_InvokeFunctionTool, Workflow_Declarative_ToolApproval) crash with KeyNotFoundException during the WORKFLOW: Restore step after a successful WORKFLOW: Yield.

Discovered via the nightly verify-samples run.

Root Cause

Bug in FileSystemJsonCheckpointStore.RetrieveCheckpointAsync (line 171):

string fileName = GetFileNameForCheckpoint(sessionId, key);  // relative filename only
string filePath = Path.Combine(this.Directory.FullName, fileName);  // full path

if (!this.CheckpointIndex.Contains(key) ||
    !File.Exists(fileName))   // BUG: resolves relative to CWD, not the store directory

File.Exists(fileName) resolves relative to the process current working directory — not the checkpoint store directory. When CWD ≠ store directory (as in CI), the file is never found, even though line 176 correctly uses filePath to open it.

Fix

  • Changed File.Exists(fileName)File.Exists(filePath) on line 171
  • Added RetrieveCheckpointAsync_ShouldReturnPersistedDataAsync roundtrip unit test (existing tests only covered CreateCheckpointAsync)

Testing

  • All 330 workflow unit tests pass (22 skipped as pre-existing flaky)
  • New roundtrip test validates create → retrieve works correctly

Copilot AI review requested due to automatic review settings April 8, 2026 14:34
@moonbox3 moonbox3 added .NET workflows Related to Workflows in agent-framework labels Apr 8, 2026
@github-actions github-actions bot changed the title Fix FileSystemJsonCheckpointStore.RetrieveCheckpointAsync using wrong path in File.Exists .NET: Fix FileSystemJsonCheckpointStore.RetrieveCheckpointAsync using wrong path in File.Exists Apr 8, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a checkpoint restore failure in the .NET workflow checkpoint store by ensuring checkpoint files are checked for existence using the store’s directory path (not the process CWD), and adds a roundtrip unit test to prevent regressions.

Changes:

  • Fix FileSystemJsonCheckpointStore.RetrieveCheckpointAsync to call File.Exists with the full checkpoint file path.
  • Add a unit test validating create → retrieve roundtrip behavior.
  • Relax two verify-samples expected-output descriptions to be less brittle for non-deterministic output verification.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
dotnet/src/Microsoft.Agents.AI.Workflows/Checkpointing/FileSystemJsonCheckpointStore.cs Corrects checkpoint existence check to use the full path in the configured store directory.
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/FileSystemJsonCheckpointStoreTests.cs Adds a regression test ensuring persisted checkpoint data can be retrieved successfully.
dotnet/eng/verify-samples/AgentsSamples.cs Updates AI-verification expectation text to tolerate natural output variability.

Copy link
Copy Markdown
Member

@lokitoth lokitoth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix

@westey-m westey-m enabled auto-merge April 8, 2026 14:39
@westey-m westey-m added this pull request to the merge queue Apr 8, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 8, 2026
@westey-m westey-m added this pull request to the merge queue Apr 8, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 8, 2026
@westey-m westey-m added this pull request to the merge queue Apr 9, 2026
Merged via the queue into microsoft:main with commit 79afda1 Apr 9, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET workflows Related to Workflows in agent-framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants