From f6b3f57e8f573769e7e7b1da43db6821930601ef Mon Sep 17 00:00:00 2001 From: ktz03 <2484593937@qq.com> Date: Fri, 16 Oct 2026 16:01:35 +0800 Subject: [PATCH 1/2] docs: align Redis context sample guide with current APIs --- .../context_providers/redis/README.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/python/samples/02-agents/context_providers/redis/README.md b/python/samples/02-agents/context_providers/redis/README.md index f4819f3f38b..4554879ac10 100644 --- a/python/samples/02-agents/context_providers/redis/README.md +++ b/python/samples/02-agents/context_providers/redis/README.md @@ -10,7 +10,7 @@ This folder contains an example demonstrating how to use the Redis context provi |------|-------------| | [`azure_redis_conversation.py`](azure_redis_conversation.py) | Demonstrates conversation persistence with RedisHistoryProvider and Azure Redis with Azure AD (Entra ID) authentication using credential provider. | | [`redis_basics.py`](redis_basics.py) | Shows standalone provider usage and agent integration. Demonstrates writing messages to Redis, retrieving context via full‑text or hybrid vector search, and persisting preferences across threads. Also includes a simple tool example whose outputs are remembered. | -| [`redis_conversation.py`](redis_conversation.py) | Simple example showing conversation persistence with RedisContextProvider using traditional connection string authentication. | +| [`redis_conversation.py`](redis_conversation.py) | Shows cross-session context retrieval with RedisContextProvider using a Redis connection URL and OpenAI embeddings. For complete conversation history persistence, use RedisHistoryProvider. | | [`redis_sessions.py`](redis_sessions.py) | Demonstrates memory scoping strategies. Includes: (1) global memory scope with `application_id`, `agent_id`, and `user_id` shared across operations; (2) hybrid vector search using a custom OpenAI vectorizer for richer context retrieval; and (3) multiple agents with isolated memory via different `agent_id` values. | @@ -21,7 +21,7 @@ This folder contains an example demonstrating how to use the Redis context provi 1. A running Redis with RediSearch (Redis Stack or a managed service) 2. Python environment with Agent Framework Redis extra installed 3. Microsoft Foundry project endpoint and Azure OpenAI Responses deployment -4. Optional: OpenAI API key if using vector embeddings +4. OpenAI API key for the OpenAI-vectorizer examples (`redis_basics.py`, `redis_conversation.py`, and the hybrid-search scenario in `redis_sessions.py`) ### Install the package @@ -53,22 +53,22 @@ See quickstart: `https://learn.microsoft.com/azure/redis/quickstart-create-manag - `FOUNDRY_PROJECT_ENDPOINT` (required): Microsoft Foundry project endpoint for `FoundryChatClient` - `FOUNDRY_MODEL` (required): Foundry model deployment name -- `OPENAI_API_KEY` (optional): Required only if you set `vectorizer_choice="openai"` to enable hybrid search. +- `OPENAI_API_KEY`: Required by the examples that instantiate `OpenAITextVectorizer` for hybrid search. ### Provider configuration highlights The provider supports both full‑text only and hybrid vector search: -- Set `vectorizer_choice` to `"openai"` or `"hf"` to enable embeddings and hybrid search. -- When using a vectorizer, also set `vector_field_name` (e.g., `"vector"`). +- Pass a RedisVL vectorizer instance, such as `OpenAITextVectorizer`, through `redis_vectorizer` and set `vector_field_name` (e.g., `"vector"`) to enable hybrid search. +- Omit `redis_vectorizer` and `vector_field_name` for full-text-only retrieval, as in the global-scope scenario in `redis_sessions.py`. - Partition fields for scoping memory: `application_id`, `agent_id`, `user_id`. -- Index management: `index_name`, `overwrite_redis_index`, `drop_redis_index`. +- Index configuration: `index_name`, `prefix`, and `overwrite_index`. ## What the example does `redis_basics.py` walks through three scenarios: -1. Standalone provider usage: adds messages and retrieves context via `invoking`. +1. Standalone provider usage: stores messages via `after_run` and retrieves context via `before_run`. 2. Agent integration: teaches the agent a preference and verifies it is remembered across turns. 3. Agent + tool: calls a sample tool (flight search) and then asks the agent to recall details remembered from the tool output. @@ -85,7 +85,7 @@ export FOUNDRY_PROJECT_ENDPOINT="https://.services.ai.azure.com/api/pr export FOUNDRY_MODEL="" ``` -3) (Optional) Set your OpenAI key if using embeddings: +3) Set your OpenAI key for `redis_basics.py` and the other OpenAI-vectorizer examples: ```bash export OPENAI_API_KEY="" @@ -108,12 +108,12 @@ You should see the agent responses and, when using embeddings, context retrieved ### Hybrid vector search (optional) -- Enable by setting `vectorizer_choice` to `"openai"` (requires `OPENAI_API_KEY`) or `"hf"` (offline model). -- Provide `vector_field_name` (e.g., `"vector"`); other vector settings have sensible defaults. +- Pass a vectorizer as `redis_vectorizer` and provide `vector_field_name` (e.g., `"vector"`). The examples use `OpenAITextVectorizer`, which requires `OPENAI_API_KEY`. +- `vector_algorithm` and `vector_distance_metric` configure the vector index; the examples use `"hnsw"` and `"cosine"`. ### Index lifecycle controls -- `overwrite_redis_index` and `drop_redis_index` help recreate indexes during iteration. +- Set `overwrite_index=True` to recreate an existing index during initialization. The examples clean up their indexes with `await provider.redis_index.delete()`. ## Troubleshooting From be77390451a17f9a396cbae1e6aa9c230e32cec5 Mon Sep 17 00:00:00 2001 From: ktz03 <2484593937@qq.com> Date: Fri, 16 Oct 2026 16:37:25 +0800 Subject: [PATCH 2/2] docs(redis): clarify sample scope and key prerequisites --- python/samples/02-agents/context_providers/redis/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/samples/02-agents/context_providers/redis/README.md b/python/samples/02-agents/context_providers/redis/README.md index 4554879ac10..6c6039a4e6c 100644 --- a/python/samples/02-agents/context_providers/redis/README.md +++ b/python/samples/02-agents/context_providers/redis/README.md @@ -10,7 +10,7 @@ This folder contains an example demonstrating how to use the Redis context provi |------|-------------| | [`azure_redis_conversation.py`](azure_redis_conversation.py) | Demonstrates conversation persistence with RedisHistoryProvider and Azure Redis with Azure AD (Entra ID) authentication using credential provider. | | [`redis_basics.py`](redis_basics.py) | Shows standalone provider usage and agent integration. Demonstrates writing messages to Redis, retrieving context via full‑text or hybrid vector search, and persisting preferences across threads. Also includes a simple tool example whose outputs are remembered. | -| [`redis_conversation.py`](redis_conversation.py) | Shows cross-session context retrieval with RedisContextProvider using a Redis connection URL and OpenAI embeddings. For complete conversation history persistence, use RedisHistoryProvider. | +| [`redis_conversation.py`](redis_conversation.py) | Shows context retrieval across conversation turns with RedisContextProvider using a Redis connection URL and OpenAI embeddings. For complete conversation history persistence, use RedisHistoryProvider. | | [`redis_sessions.py`](redis_sessions.py) | Demonstrates memory scoping strategies. Includes: (1) global memory scope with `application_id`, `agent_id`, and `user_id` shared across operations; (2) hybrid vector search using a custom OpenAI vectorizer for richer context retrieval; and (3) multiple agents with isolated memory via different `agent_id` values. | @@ -21,7 +21,7 @@ This folder contains an example demonstrating how to use the Redis context provi 1. A running Redis with RediSearch (Redis Stack or a managed service) 2. Python environment with Agent Framework Redis extra installed 3. Microsoft Foundry project endpoint and Azure OpenAI Responses deployment -4. OpenAI API key for the OpenAI-vectorizer examples (`redis_basics.py`, `redis_conversation.py`, and the hybrid-search scenario in `redis_sessions.py`) +4. OpenAI API key for the OpenAI-vectorizer examples (`redis_basics.py`, `redis_conversation.py`, and the hybrid-search and multiple-agents scenarios in `redis_sessions.py`) ### Install the package