.NET: Adds Valkey to chat message history - issue 5445#5542
.NET: Adds Valkey to chat message history - issue 5445#5542MatthiasHowellYopp wants to merge 2 commits into
Conversation
2598a07 to
4958338
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Completes the new .NET Valkey integration by adding Valkey-backed chat history/context providers, unit tests, and two samples (Azure OpenAI + Amazon Bedrock), plus wiring the new projects into the solution and central package versions.
Changes:
- Added
Microsoft.Agents.AI.Valkeypackage implementation:ValkeyChatHistoryProvider,ValkeyContextProvider, andValkeyProviderScope. - Added a new Valkey unit test project with coverage for provider behavior and scope cloning.
- Added new AgentWithMemory step 03 samples (Azure OpenAI + Bedrock), plus solution and package version updates.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/tests/Microsoft.Agents.AI.Valkey.UnitTests/ValkeyContextProviderTests.cs | Adds unit tests for ValkeyContextProvider behaviors (escaping, parsing, disposal, scope/state). |
| dotnet/tests/Microsoft.Agents.AI.Valkey.UnitTests/ValkeyChatHistoryProviderTests.cs | Adds unit tests for ValkeyChatHistoryProvider behaviors (store/retrieve/trim/dispose). |
| dotnet/tests/Microsoft.Agents.AI.Valkey.UnitTests/TestHelpers.cs | Adds shared test helpers for constructing provider invoke contexts and a test AgentSession. |
| dotnet/tests/Microsoft.Agents.AI.Valkey.UnitTests/Microsoft.Agents.AI.Valkey.UnitTests.csproj | Introduces the Valkey unit test project. |
| dotnet/src/Microsoft.Agents.AI.Valkey/ValkeyProviderScope.cs | Adds ValkeyProviderScope including copy constructor and XML docs. |
| dotnet/src/Microsoft.Agents.AI.Valkey/ValkeyContextProvider.cs | Introduces Valkey full-text-search-backed long-term memory/context provider. |
| dotnet/src/Microsoft.Agents.AI.Valkey/ValkeyChatHistoryProvider.cs | Introduces Valkey-backed persistent chat history provider using list operations. |
| dotnet/src/Microsoft.Agents.AI.Valkey/Microsoft.Agents.AI.Valkey.csproj | Adds new Valkey project with dependencies and InternalsVisibleTo for tests. |
| dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step03_MemoryUsingValkey_Bedrock/README.md | Adds Bedrock+Valkey sample documentation. |
| dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step03_MemoryUsingValkey_Bedrock/Program.cs | Adds Bedrock-powered sample using both Valkey providers. |
| dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step03_MemoryUsingValkey_Bedrock/AgentWithMemory_Step03_MemoryUsingValkey_Bedrock.csproj | Adds Bedrock sample project and dependency on AWSSDK.Extensions.Bedrock.MEAI. |
| dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step03_MemoryUsingValkey/README.md | Adds Azure OpenAI+Valkey sample documentation. |
| dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step03_MemoryUsingValkey/Program.cs | Adds Azure OpenAI powered sample using both Valkey providers. |
| dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step03_MemoryUsingValkey/AgentWithMemory_Step03_MemoryUsingValkey.csproj | Adds Azure OpenAI sample project references. |
| dotnet/agent-framework-dotnet.slnx | Registers the new Valkey project, new Valkey unit tests, and new samples in the solution. |
| dotnet/Directory.Packages.props | Adds centrally managed version for AWSSDK.Extensions.Bedrock.MEAI. |
| .gitignore | Ignores .kiro/ folder. |
ab4e77d to
4f45ce9
Compare
16dc043 to
09145fa
Compare
8036db8 to
a3186e1
Compare
|
@westey-m Hoping I can get a review on this this week, tks |
786c06a to
ecbe5e6
Compare
Thanks for the contribution @MatthiasHowellYopp. I've added a few comments. |
|
Thanks for the thorough review @westey-m — pushed updates addressing all feedback: Changes made: Switched from StackExchange.Redis to Valkey.Glide 1.1.0 (official Valkey .NET client, GA'd April 2026). This resolves the naming question — we're now using the Valkey-native client library. Extracted optional params into ValkeyChatHistoryProviderOptions following the InMemoryChatHistoryProviderOptions pattern. Constructor is now (IConnectionMultiplexer, Func, Options?, ILoggerFactory?). Added JsonSerializerOptions to options, passed through to ProviderSessionState. Removed class-level [RequiresUnreferencedCode]/[RequiresDynamicCode]. MaxMessages/MaxMessagesToRetrieve are now private readonly fields set from options. Removed ValkeyContextProvider and ValkeyProviderScope — agree it overlaps with ChatHistoryMemoryProvider + MEVD. Can revisit as a separate enhancement if there's a distinct use case for full-text search without embeddings. Updated model name in sample. |
…text provider - Switch from StackExchange.Redis to Valkey.Glide 1.1.0 (official Valkey .NET client) - Extract optional params into ValkeyChatHistoryProviderOptions - Add JsonSerializerOptions support, remove [RequiresUnreferencedCode] - Make MaxMessages/MaxMessagesToRetrieve readonly via options - Remove ValkeyContextProvider (overlaps with ChatHistoryMemoryProvider + MEVD) - Remove ValkeyProviderScope (only used by context provider) - Remove connection string constructors (caller manages IConnectionMultiplexer) - Update samples to use new API and gpt-5.4-mini
ecbe5e6 to
0a13ccb
Compare
Motivation and Context
The .NET Agent Framework currently has no dedicated Valkey integration package. Teams running Valkey in production — whether self-hosted or through managed cloud services like AWS ElastiCache for Valkey or GCP Memorystore for Valkey — have no first-party way to use Valkey for persistent chat history or long-term memory context. This has become increasingly common since the Redis license change.
The Microsoft.Agents.AI.Valkey package was scaffolded with working ValkeyChatHistoryProvider and ValkeyContextProvider implementations. This PR completes the package by adding missing pieces identified during review, fixing bugs in the existing sample, and adding a Bedrock-powered sample for AWS users.
Fixes issue #5445
Description
###Valkey package improvements:
###Bug fix in existing sample:
###New Bedrock sample (AgentWithMemory_Step03_MemoryUsingValkey_Bedrock):
###Infrastructure:
Unit tests:
Added tests for ValkeyProviderScope copy constructor (clone all properties, null source throws)
23 tests total, all passing
Contribution Checklist
[x] The code builds clean without any errors or warnings
[x] The PR follows the Contribution Guidelines
[x] 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.