agent-framework-redis 1.0.0b260918


pip install agent-framework-redis

  Latest version

Released: Sep 18, 2026


Meta
Author: Microsoft
Requires Python: >=3.10

Classifiers

License
  • OSI Approved :: MIT License

Development Status
  • 4 - Beta

Intended Audience
  • Developers

Programming Language
  • Python :: 3
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14

Typing
  • Typed

Microsoft Agent Framework Redis

Redis-backed conversation history, memory retrieval, and vector storage for Microsoft Agent Framework.

Choose the right component

Your goal Component
Persist ordered conversation messages across runs and application restarts RedisHistoryProvider
Retrieve relevant memories and add them to an agent's context RedisContextProvider
Store and search your own documents or embeddings RedisCollection (experimental)
Manage vector collections with a shared connection and namespace RedisStore (experimental)
Resolve vector-store connection configuration from arguments, .env, or environment variables RedisSettings

These components can be used together, but do not automatically share stored records. Import them from agent_framework.redis or agent_framework_redis.

Install

Requires Python 3.10 or later:

pip install agent-framework-redis --pre

Run Redis

Choose a managed service or run Redis locally:

  • Azure Managed Redis: Run Redis as a managed Azure service. Follow the Azure Managed Redis quickstart to create an instance.

  • Redis Cloud: Use Redis Cloud for a fully managed Redis database.

  • Local Docker: Start Redis on your machine with:

    docker run --rm --name agent-framework-redis -p 127.0.0.1:6379:6379 redis:8.0.3
    

For managed services, choose a configuration with the Search/JSON capabilities required by your component below, and use the service's connection endpoint and authentication settings.

Requirements and configuration

Conversation history uses Redis Lists and does not require Search or RedisJSON. Context retrieval requires Redis Search. Vector collections require Redis 8.0.3 or later with Search, including INDEXMISSING and INDEXEMPTY support; JSON collections additionally require RedisJSON. Redis Search indexes require logical database 0, so vector-store URLs and clients must select database 0 (the default).

Choose storage_type="hash" for non-null records with binary vector storage, or "json" for nullable fields/vectors and native JSON data. HASH rejects None, including vector=None; JSON preserves explicit null. Both support multiple vector fields and FLAT/HNSW indexes.

RedisCollection and RedisStore use RedisSettings with the Agent Framework settings loader. Connection precedence is an explicit redis_url, then REDIS_URL in a supplied env_file_path, then the process environment, with redis://localhost:6379 as the default. Settings mask credential-bearing URLs with SecretString; use rediss:// when your server requires TLS.

You may supply a standalone redis.asyncio.Redis client using decode_responses=False and RESP2. Both URL-created and supplied clients must use strict UTF-8 encoding (encoding="utf-8", encoding_errors="strict", the defaults) so Unicode keys and string fields round-trip without lossy conversions. Incompatible encoding or database settings are rejected before connecting. Supplied clients take precedence over URL settings and remain caller-owned. Closing a store closes its owned connection, not its stored data. Redis Cluster clients are not supported.

Vector collections support dense search and a subset of portable filters, not hybrid/full-text search or literal substring/prefix/suffix filters. JSON null checks are supported on numeric and boolean fields, not strings or arrays. Indexed strings cannot contain surrounding whitespace, NUL, or U+001F, and must fit Redis's 4096-byte TAG limit; these restrictions do not apply to unindexed payloads. Unsupported operations raise an error.

Isolate conversation history

RedisHistoryProvider uses scoped keys by default. Supply a stable application_id; also supply tenant_id and agent_id whenever those boundaries exist in your application. The provider's source_id and each non-empty session ID are included automatically:

from agent_framework.redis import RedisHistoryProvider

history_provider = RedisHistoryProvider(
    redis_url="redis://localhost:6379",
    application_id="support-app",
    tenant_id="contoso",
    agent_id="triage-agent",
)

Scoped mode rejects missing application or session identifiers rather than placing unrelated conversations under a shared fallback key. Identifiers are encoded independently, so they do not need to be globally unique across tenants, applications, agents, and provider sources.

Releases that predate scoped keys used {key_prefix}:{session_id or "default"}. Existing deployments can temporarily retain that exact format by opting in explicitly:

legacy_history_provider = RedisHistoryProvider(
    redis_url="redis://localhost:6379",
    key_format="legacy",
)

Legacy mode does not accept scoped identifiers. Scoped mode never reads, rewrites, or deletes legacy keys. To migrate existing history, copy only the records belonging to a verified application, tenant, agent, provider source, and session into the corresponding scoped key using an application-owned migration process. After verifying the copied history, remove legacy keys separately according to the application's retention policy.

Store and search documents

This example uses precomputed vectors, so no embedding service is needed. It connects using REDIS_URL or the localhost default:

import asyncio
from dataclasses import dataclass
from typing import Annotated

from agent_framework import VectorStoreField, vectorstoremodel
from agent_framework.redis import RedisStore


@vectorstoremodel
@dataclass
class Document:
    id: Annotated[str, VectorStoreField("key")]
    text: Annotated[str, VectorStoreField("data")]
    vector: Annotated[
        list[float] | None,
        VectorStoreField("vector", dimensions=2, index_kind="flat"),
    ] = None


async def main() -> None:
    async with RedisStore(storage_type="json", namespace="my-app") as store:
        collection = store.get_collection(Document, collection_name="documents")
        await collection.ensure_collection_exists()
        await collection.upsert(
            [Document("one", "A guide to Redis", [1.0, 0.0])],
            generate_vectors=False,
        )
        results = await collection.search(vector=[1.0, 0.0], top=3)
        async for result in results:
            print(result["record"].text, result["score"])


asyncio.run(main())

CRUD operations accept batches. Provide an embedding generator to generate vectors automatically, or use generate_vectors=False to keep supplied vectors. Retrieval excludes vectors by default; use include_vectors=True to return them. Search scores are native distances (cosine distance by default), where lower is better; a nonnegative score_threshold sets a maximum distance before paging.

Documentation and examples

1.0.0b260918 Sep 18, 2026
1.0.0b260910 Sep 10, 2026
1.0.0b260903 Sep 03, 2026
1.0.0b260821 Aug 21, 2026
1.0.0b260813 Aug 14, 2026
1.0.0b260730 Jul 30, 2026
1.0.0b260721 Jul 21, 2026
1.0.0b260521 May 22, 2026
1.0.0b260519 May 20, 2026
1.0.0b260514 May 15, 2026
1.0.0b260507 May 08, 2026
1.0.0b260429 Apr 29, 2026
1.0.0b260428 Apr 28, 2026
1.0.0b260424 Apr 24, 2026
1.0.0b260423 Apr 23, 2026
1.0.0b260421 Apr 21, 2026
1.0.0b260409 Apr 10, 2026
1.0.0b260402 Apr 02, 2026
1.0.0b260330 Mar 30, 2026
1.0.0b260319 Mar 20, 2026
1.0.0b260311 Mar 11, 2026
1.0.0b260304 Mar 04, 2026
1.0.0b260225 Feb 26, 2026
1.0.0b260219 Feb 20, 2026
1.0.0b260212 Feb 13, 2026
1.0.0b260210 Feb 11, 2026
1.0.0b260130 Jan 30, 2026
1.0.0b260128 Jan 28, 2026
1.0.0b260127 Jan 27, 2026
1.0.0b260123 Jan 23, 2026
1.0.0b260116 Jan 16, 2026
1.0.0b260114 Jan 14, 2026
1.0.0b260107 Jan 07, 2026
1.0.0b260106 Jan 07, 2026
1.0.0b251223 Dec 24, 2025
1.0.0b251218 Dec 19, 2025
1.0.0b251216 Dec 17, 2025
1.0.0b251211 Dec 11, 2025
1.0.0b251209 Dec 09, 2025
1.0.0b251204 Dec 04, 2025
1.0.0b251120 Nov 21, 2025
1.0.0b251114 Nov 15, 2025
1.0.0b251112.post1 Nov 13, 2025
1.0.0b251112 Nov 13, 2025
1.0.0b251111 Nov 11, 2025
1.0.0b251108 Nov 08, 2025
1.0.0b251105 Nov 05, 2025
1.0.0b251104 Nov 04, 2025
1.0.0b251028 Oct 28, 2025
1.0.0b251016 Oct 16, 2025
1.0.0b251007 Oct 07, 2025
1.0.0b251001 Oct 01, 2025
Extras: None
Dependencies:
agent-framework-core (<2,>=1.19.0)
redis (<7.2.1,>=6.4.0)
redisvl (<0.16,>=0.11.0)
numpy (<3,>=2.2.6)