microsoft / microsoft/agent-framework

Python: .NET: [Feature]: Add Valkey Context Provider and Chat Message Store

Open
#5,445 2 comments 0 reactions 1 assignee View on GitHub

@westey-m is already working on this.

Since Apr 23, 2026.

.NET agents python
Dominant language
Python
Stars
13.6k
Forks
2.3k
Avg merge
2d 45m
Merged PRs (30d)
358

Description

Description

##Problem
The .NET Agent Framework currently has no dedicated Valkey integration package. While StackExchange.Redis (already in Directory.Packages.props) is protocol-compatible with Valkey for basic key-value operations, there is no ChatHistoryProvider or AIContextProvider implementation backed by Valkey.

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 in the .NET Agent Framework. This has become increasingly common since the Redis license change.

##Proposed Solution
Add a new Microsoft.Agents.AI.Valkey NuGet package providing:

  • ValkeyChatHistoryProvider — persistent chat history implementing ChatHistoryProvider, using StackExchange.Redis (which is protocol-compatible with Valkey) for basic key-value/list operations. Follows the same patterns as CosmosChatHistoryProvider with state management via ProviderSessionState, configurable message limits, and session-scoped isolation.

  • ValkeyContextProvider — long-term memory context provider extending MessageAIContextProvider, using Valkey's native vector search capabilities (FT.CREATE / FT.SEARCH) for semantic retrieval of past conversation context. Follows the same patterns as Mem0Provider with configurable scopes, context prompts, and message filtering.

The package would follow the same structure and patterns as Microsoft.Agents.AI.CosmosNoSql (for ChatHistoryProvider) and Microsoft.Agents.AI.Mem0 (for AIContextProvider).

##Server Requirements

  • ValkeyChatHistoryProvider: Works with any Valkey (or Redis OSS) server — basic key-value operations only.

  • ValkeyContextProvider: Requires valkey-search >= 1.2 (ships with valkey-bundle >= 9.1.0). Can be tested on valkey/valkey-bundle:9.1.0-rc1.

  • Value

  • Performance: Valkey's valkey-search module delivers single-digit millisecond latency with 99%+ recall for vector search operations

  • Scaling: Linear scaling with cluster mode support

  • Open-source governance: Linux Foundation project with community-driven development, clear licensing

  • Cloud support: Managed services from AWS, GCP, and other major cloud providers

  • Migration path: Easy migration from Redis deployments for teams affected by the Redis license change

  • Parity: Companion to the Python agent-framework-valkey package (see #5260)

Code Sample
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.Valkey;

// Chat history provider — basic key-value operations, no search module needed
var historyProvider = new ValkeyChatHistoryProvider(
    connectionString: "localhost:6379",
    stateInitializer: session => new ValkeyChatHistoryProvider.State { ConversationId = session?.Id ?? "default" });

// Context provider — requires valkey-search module
var contextProvider = new ValkeyContextProvider(
    connectionString: "localhost:6379",
    stateInitializer: session => new ValkeyContextProvider.State
    {
        SearchScope = new ValkeyProviderScope { UserId = "user-123" },
        StorageScope = new ValkeyProviderScope { UserId = "user-123" }
    });

var agent = new ChatClientAgent(chatClient, "HelpfulBot")
{
    ChatHistoryProvider = historyProvider,
    ContextProviders = { contextProvider }
};
Language/SDK

.NET

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.