Skip to content

.NET: Fix issue with resuming checkpoint after package version upgrade#6670

Draft
peibekwe wants to merge 1 commit into
mainfrom
peibekwe/durable-task-version-resume
Draft

.NET: Fix issue with resuming checkpoint after package version upgrade#6670
peibekwe wants to merge 1 commit into
mainfrom
peibekwe/durable-task-version-resume

Conversation

@peibekwe

Copy link
Copy Markdown
Contributor

Motivation & Context

When you upgrade the Microsoft.Agents.AI.DurableTask package and redeploy, any saved workflow checkpoint from the previous version becomes unusable. The framework refuses to load it, even though nothing about the workflow actually changed; only the package's version number did.

Description & Review Guide

This ports the fix applied to core workflows in PR #6636 to DurableTask.

Fixes #6669

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

@peibekwe peibekwe self-assigned this Jun 22, 2026
Copilot AI review requested due to automatic review settings June 22, 2026 18:27
@moonbox3 moonbox3 added the .NET Usage: [Issues, PRs], Target: .Net label Jun 22, 2026
@github-actions github-actions Bot changed the title Fix issue with resuming checkpoint after package version upgrade .NET: Fix issue with resuming checkpoint after package version upgrade Jun 22, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated Code Review

Reviewers: 5 | Confidence: 92% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Failure Modes, Design Approach


Automated review by peibekwe's agents

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Ports the workflows checkpoint-compatibility fix to the DurableTask implementation so persisted assembly-qualified type names (from checkpoints/custom status payloads) can be resolved after package upgrades where only assembly version/culture/PKT metadata changed.

Changes:

  • Add DurableTaskTypeResolver to normalize persisted type names and resolve them against loaded assemblies.
  • Use the resolver when deserializing streamed workflow events and when resolving executor input types.
  • Add unit tests covering mutated assembly versions (outer and generic-argument cases) and the streaming deserialization path.

Reviewed changes

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

Show a summary per file
File Description
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableTaskTypeResolver.cs New resolver that normalizes persisted assembly-qualified names and caches resolution.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableStreamingWorkflowRun.cs Switch event type lookup to use the new resolver during stream parsing.
dotnet/src/Microsoft.Agents.AI.DurableTask/Workflows/DurableActivityExecutor.cs Use the resolver to match persisted input type names to supported executor input types across version changes.
dotnet/tests/Microsoft.Agents.AI.DurableTask.UnitTests/Workflows/DurableTaskTypeResolverTests.cs New tests validating type resolution across assembly metadata mutations.
dotnet/tests/Microsoft.Agents.AI.DurableTask.UnitTests/Workflows/DurableActivityExecutorResolveInputTypeTests.cs New tests validating input-type matching behavior across metadata mutations.
dotnet/tests/Microsoft.Agents.AI.DurableTask.UnitTests/Workflows/DurableStreamingWorkflowRunTests.cs New test validating mutated event type names still deserialize during WatchStreamAsync.

Comment on lines +16 to +38
private static readonly ConcurrentDictionary<string, Type?> s_cache = new();

/// <summary>
/// Resolves <paramref name="typeName"/> using a qualified <see cref="Type.GetType(string, bool)"/>
/// lookup, then a partial-name fallback that strips embedded version, culture, and public key
/// token qualifiers.
/// </summary>
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access", Justification = "Workflow message and event types are registered at startup.")]
[UnconditionalSuppressMessage("Trimming", "IL2057:Unrecognized value passed to the parameter of method", Justification = "Workflow message and event types are registered at startup.")]
internal static Type? Resolve(string typeName)
=> s_cache.GetOrAdd(typeName, static name =>
{
Type? type = Type.GetType(name, throwOnError: false);
if (type is not null)
{
return type;
}

string normalized = TypeId.NormalizeTypeName(name);
return ReferenceEquals(normalized, name)
? null
: Type.GetType(normalized, throwOnError: false);
});
Comment on lines +9 to +13
/// <summary>
/// Resolves persisted assembly-qualified type-name strings to a loaded <see cref="Type"/>,
/// tolerating differences in assembly version, culture, and public key token between the
/// persisted name and the currently loaded assemblies. Results are cached.
/// </summary>
Comment on lines +17 to +22
public void ResolveInputType_NullInput_ReturnsFirstSupportedType()
{
Type result = DurableActivityExecutor.ResolveInputType(null, new HashSet<Type> { typeof(int), typeof(string) });

Assert.Equal(typeof(int), result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Usage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [Bug]: DurableTask Workflow checkpoints are not restorable across SDK upgrades

3 participants