Skip to content

Conversation

@ysya
Copy link

@ysya ysya commented Dec 11, 2025

Motivation and Context

Related to #2401 (C# implementation) The Agent Framework currently supports only in-memory and flat file checkpoint storage, which limits adoption in production environments. Workflows often need to be resumed across processes, pods, or machines, requiring a distributed and durable checkpoint store.

Description

Implement RedisCheckpointStore for distributed, durable checkpoint storage in .NET:

Features:

  • Support connection string, ConfigurationOptions, and IConnectionMultiplexer for flexible Redis connectivity
  • TTL-based automatic checkpoint expiration via RedisCheckpointStoreOptions.TimeToLive
  • Parent-child checkpoint relationships for workflow history tracking
  • Configurable key prefix and Redis database selection
  • Extension methods (CreateRedisCheckpointStore, CreateRedisCheckpointStoreWithTtl) for easy integration

Files added:

  • src/Microsoft.Agents.AI.Redis/ - Core implementation
  • tests/Microsoft.Agents.AI.Redis.UnitTests/ - Unit tests (27 tests)
  • samples/GettingStarted/Workflows/Checkpoint/CheckpointWithRedis/ - Sample application

Dependencies:
Uses StackExchange.Redis for connection pooling and resilience
Follows the same patterns as Microsoft.Agents.AI.CosmosNoSql

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Implement RedisCheckpointStore for distributed, durable checkpoint storage:
- Support connection string, ConfigurationOptions, and IConnectionMultiplexer
- TTL-based automatic checkpoint expiration
- Parent-child checkpoint relationships for workflow history tracking
- Extension methods for easy integration

Includes unit tests and sample application.
Copilot AI review requested due to automatic review settings December 11, 2025 21:12
Copy link
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

This PR adds a Redis-based checkpoint store implementation for the Agent Framework's workflow system, enabling distributed and durable checkpoint storage in production environments. The implementation follows the existing patterns from Microsoft.Agents.AI.CosmosNoSql.

Key changes:

  • New RedisCheckpointStore with support for TTL-based expiration and parent-child checkpoint relationships
  • Comprehensive unit test suite with 27 tests using skippable facts for Redis availability
  • Sample application demonstrating Redis checkpoint usage with workflow state management

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
dotnet/src/Microsoft.Agents.AI.Redis/RedisCheckpointStore.cs Core Redis checkpoint store implementation with generic and non-generic variants
dotnet/src/Microsoft.Agents.AI.Redis/RedisCheckpointStoreOptions.cs Configuration options for key prefix, TTL, and database selection
dotnet/src/Microsoft.Agents.AI.Redis/RedisWorkflowExtensions.cs Extension methods for creating checkpoint stores with various configurations
dotnet/src/Microsoft.Agents.AI.Redis/Microsoft.Agents.AI.Redis.csproj Project file with StackExchange.Redis dependency
dotnet/tests/Microsoft.Agents.AI.Redis.UnitTests/RedisCheckpointStoreTests.cs Comprehensive test suite covering all checkpoint operations
dotnet/tests/Microsoft.Agents.AI.Redis.UnitTests/RedisCollectionFixture.cs Test collection fixture to prevent parallel test execution
dotnet/tests/Microsoft.Agents.AI.Redis.UnitTests/Microsoft.Agents.AI.Redis.UnitTests.csproj Test project configuration
dotnet/samples/GettingStarted/Workflows/Checkpoint/CheckpointWithRedis/Program.cs Sample demonstrating Redis checkpoint usage with parent-child relationships
dotnet/samples/GettingStarted/Workflows/Checkpoint/CheckpointWithRedis/CheckpointWithRedis.csproj Sample project configuration
dotnet/agent-framework-dotnet.slnx Solution file updates to include new projects
dotnet/Directory.Packages.props Added StackExchange.Redis package version

Comment on lines +92 to +96
if (this._disposed)
{
throw new ObjectDisposedException(this.GetType().FullName);
}
#pragma warning restore CA1513
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The '_disposed' field is checked without thread synchronization. In multi-threaded scenarios, this could lead to race conditions where Dispose is called while an operation is in progress. Consider using a lock or volatile keyword, or better yet, use ObjectDisposedException.ThrowIf with proper synchronization.

Copilot uses AI. Check for mistakes.
Comment on lines +149 to +153
if (this._disposed)
{
throw new ObjectDisposedException(this.GetType().FullName);
}
#pragma warning restore CA1513
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The '_disposed' field is checked without thread synchronization. In multi-threaded scenarios, this could lead to race conditions where Dispose is called while an operation is in progress. Consider using a lock or volatile keyword, or better yet, use ObjectDisposedException.ThrowIf with proper synchronization.

Copilot uses AI. Check for mistakes.
Comment on lines +182 to +186
if (this._disposed)
{
throw new ObjectDisposedException(this.GetType().FullName);
}
#pragma warning restore CA1513
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The '_disposed' field is checked without thread synchronization. In multi-threaded scenarios, this could lead to race conditions where Dispose is called while an operation is in progress. Consider using a lock or volatile keyword, or better yet, use ObjectDisposedException.ThrowIf with proper synchronization.

Copilot uses AI. Check for mistakes.

protected virtual void Dispose(bool disposing)
{
// Connection multiplexer disposed in DisposeAsync
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The 'disposing' parameter is not used in the Dispose method. While this is a valid pattern for implementing IDisposable, the parameter should either be used or the method body should indicate why it's not needed with a comment.

Suggested change
// Connection multiplexer disposed in DisposeAsync
// The 'disposing' parameter is unused because connection multiplexer is disposed in DisposeAsync.

Copilot uses AI. Check for mistakes.
…ithRedis/CheckpointWithRedis.csproj

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants