Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ temp*/

# AI
.claude/
.kiro/
.omc/
.omx/
WARP.md
Expand Down
1 change: 1 addition & 0 deletions python/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ python/
### Storage & Memory
- [mem0](packages/mem0/AGENTS.md) - Mem0 memory integration
- [redis](packages/redis/AGENTS.md) - Redis storage
- [valkey](packages/valkey/AGENTS.md) - Valkey storage and vector search

### Infrastructure
- [copilotstudio](packages/copilotstudio/AGENTS.md) - Microsoft Copilot Studio
Expand Down
1 change: 1 addition & 0 deletions python/PACKAGE_STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Status is grouped into these buckets:
| `agent-framework-orchestrations` | `python/packages/orchestrations` | `beta` |
| `agent-framework-purview` | `python/packages/purview` | `beta` |
| `agent-framework-redis` | `python/packages/redis` | `beta` |
| `agent-framework-valkey` | `python/packages/valkey` | `alpha` |

## Deprecated / removed packages

Expand Down
23 changes: 23 additions & 0 deletions python/packages/valkey/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Valkey Package (agent-framework-valkey)

Valkey-based storage for agent conversations and context.

## Main Classes

- **`ValkeyChatMessageStore`** - Persistent chat history provider using Valkey
- **`ValkeyContextProvider`** - Context provider with Valkey-backed vector search retrieval

## Usage

```python
from agent_framework_valkey import ValkeyContextProvider, ValkeyChatMessageStore

context_provider = ValkeyContextProvider(host="localhost", port=6379, user_id="u1")
message_store = ValkeyChatMessageStore(host="localhost", port=6379)
```

## Import Path

```python
from agent_framework_valkey import ValkeyContextProvider, ValkeyChatMessageStore
```
21 changes: 21 additions & 0 deletions python/packages/valkey/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Microsoft Corporation.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
115 changes: 115 additions & 0 deletions python/packages/valkey/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Get Started with Microsoft Agent Framework Valkey

Please install this package via pip:

```bash
pip install agent-framework-valkey --pre
```

## Server Requirements

The `ValkeyChatMessageStore` works with any Valkey (or Redis OSS) server — it only uses basic key-value operations.

The `ValkeyContextProvider` requires the **valkey-search** module (>= 1.2) for its `FT.CREATE` / `FT.SEARCH` commands. This module ships with **valkey-bundle >= 9.1.0** and is also available in managed cloud offerings (AWS ElastiCache for Valkey, GCP Memorystore for Valkey).

For local development and testing, use `valkey-bundle 9.1.0-rc1`:

```bash
docker run -d --name valkey -p 6379:6379 valkey/valkey-bundle:9.1.0-rc1
```

## Components

### Valkey Context Provider

The `ValkeyContextProvider` enables persistent context and memory capabilities for your agents,
allowing them to remember user preferences and conversation context across sessions and threads.
It uses Valkey's native vector search capabilities (`FT.CREATE` / `FT.SEARCH`) for semantic
retrieval of past conversation context.

#### Basic Usage

```python
from agent_framework_valkey import ValkeyContextProvider

# Text-only search (no embeddings required)
context_provider = ValkeyContextProvider(
host="localhost",
port=6379,
user_id="user-123",
)

# With vector search (requires an embedding function)
async def my_embed_fn(text: str) -> list[float]:
# Your embedding logic here
...

context_provider = ValkeyContextProvider(
host="localhost",
port=6379,
user_id="user-123",
embed_fn=my_embed_fn,
vector_field_name="embedding",
vector_dims=1536,
)
```

### Valkey Chat Message Store

The `ValkeyChatMessageStore` provides persistent conversation storage using Valkey Lists,
enabling chat history to survive application restarts and support distributed applications.

#### Key Features

- **Persistent Storage**: Messages survive application restarts
- **Session Isolation**: Each conversation session has its own Valkey key
- **Message Limits**: Configurable automatic trimming of old messages
- **Lightweight**: Uses only basic Valkey key-value operations (no search module required)
- **valkey-glide**: Built on the official Valkey Python client

#### Basic Usage

```python
from agent_framework_valkey import ValkeyChatMessageStore

store = ValkeyChatMessageStore(
host="localhost",
port=6379,
max_messages=100,
)
```

## Installing and Running Valkey

### Option A: Local Valkey with Docker

For basic chat history storage (no search needed):

```bash
docker run --name valkey -p 6379:6379 -d valkey/valkey:8.1
```

For full functionality including the `ValkeyContextProvider` (requires valkey-search):

```bash
docker run --name valkey -p 6379:6379 -d valkey/valkey-bundle:9.1.0-rc1
```

### Option B: AWS ElastiCache for Valkey

Create a serverless or node-based [ElastiCache for Valkey](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/WhatIs.html) cluster.

### Option C: Google Cloud Memorystore for Valkey

Create a [Memorystore for Valkey](https://cloud.google.com/memorystore/docs/valkey) instance.

## Why Valkey?

Valkey is an open-source, Linux Foundation project that is protocol-compatible with Redis
for core operations. It provides:

- **Open governance**: Community-driven development under the Linux Foundation
- **Performance**: Single-digit millisecond latency with high recall for vector search
- **Scaling**: Linear scaling with cluster mode support
- **Cloud support**: Managed services from AWS, GCP, and other providers
- **Migration path**: Drop-in replacement for Redis deployments
27 changes: 27 additions & 0 deletions python/packages/valkey/agent_framework_valkey/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) Microsoft. All rights reserved.

"""Valkey integration for Microsoft Agent Framework.

This module re-exports objects from:
- agent-framework-valkey

Supported classes:
- ValkeyContextProvider
- ValkeyChatMessageStore
"""

import importlib.metadata

from ._chat_message_store import ValkeyChatMessageStore
from ._context_provider import ValkeyContextProvider

try:
__version__ = importlib.metadata.version(__name__)
except importlib.metadata.PackageNotFoundError:
__version__ = "0.0.0" # Fallback for development mode

__all__ = [
"ValkeyChatMessageStore",
"ValkeyContextProvider",
"__version__",
]
Loading
Loading