From cb47f6c8387c1f306b455a84d1dec25b48f38353 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 14:29:08 +0000 Subject: [PATCH 1/7] Initial plan From 4e3c658077147e7c0bb25e75eee2dde54004eaf1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 14:32:28 +0000 Subject: [PATCH 2/7] Fix: Replace alpha with linear_alpha in HybridQuery for redisvl 0.14.0 compatibility Co-authored-by: markwallace-microsoft <127216156+markwallace-microsoft@users.noreply.github.com> --- .../_context_provider.py | 2 +- python/packages/redis/tests/test_providers.py | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/python/packages/redis/agent_framework_redis/_context_provider.py b/python/packages/redis/agent_framework_redis/_context_provider.py index e8e0dbd66e..b4d0500345 100644 --- a/python/packages/redis/agent_framework_redis/_context_provider.py +++ b/python/packages/redis/agent_framework_redis/_context_provider.py @@ -373,7 +373,7 @@ async def _redis_search( vector_field_name=self.vector_field_name, text_scorer=text_scorer, filter_expression=combined_filter, - alpha=alpha, + linear_alpha=alpha, dtype=self.redis_vectorizer.dtype, num_results=num_results, return_fields=return_fields, diff --git a/python/packages/redis/tests/test_providers.py b/python/packages/redis/tests/test_providers.py index 9bd388517d..8a73ff3eb7 100644 --- a/python/packages/redis/tests/test_providers.py +++ b/python/packages/redis/tests/test_providers.py @@ -240,6 +240,48 @@ async def test_aenter_returns_self(self, patch_index_from_dict: MagicMock): # n assert p is provider +class TestRedisContextProviderHybridQuery: + """Test for HybridQuery parameter compatibility with redisvl 0.14.0.""" + + async def test_hybrid_query_uses_linear_alpha( + self, + mock_index: AsyncMock, + patch_index_from_dict: MagicMock, # noqa: ARG002 + ): + """Ensure HybridQuery is called with linear_alpha parameter for redisvl 0.14.0+.""" + from unittest.mock import AsyncMock as AM + from unittest.mock import MagicMock as MM + + from redisvl.utils.vectorize import BaseVectorizer + + # Create a mock vectorizer that inherits from BaseVectorizer + mock_vectorizer = MM(spec=BaseVectorizer) + mock_vectorizer.dims = 128 + mock_vectorizer.dtype = "float32" + mock_vectorizer.aembed = AM(return_value=[0.1] * 128) + + mock_index.query = AsyncMock(return_value=[{"content": "test result"}]) + + provider = RedisContextProvider( + source_id="ctx", + user_id="u1", + redis_vectorizer=mock_vectorizer, + vector_field_name="embedding", + ) + + # Call _redis_search with custom alpha + with patch("agent_framework_redis._context_provider.HybridQuery") as mock_hybrid_query: + mock_hybrid_query.return_value = MM() + await provider._redis_search(text="test query", alpha=0.5) + + # Verify HybridQuery was called with linear_alpha, not alpha + mock_hybrid_query.assert_called_once() + call_kwargs = mock_hybrid_query.call_args.kwargs + assert "linear_alpha" in call_kwargs + assert call_kwargs["linear_alpha"] == 0.5 + assert "alpha" not in call_kwargs + + # =========================================================================== # RedisHistoryProvider tests # =========================================================================== From f3b0130ecce3620a5c92d728a9da4e3f1ed6556d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 14:33:31 +0000 Subject: [PATCH 3/7] Address code review: Improve test readability and add explanatory comment Co-authored-by: markwallace-microsoft <127216156+markwallace-microsoft@users.noreply.github.com> --- python/packages/redis/tests/test_providers.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/python/packages/redis/tests/test_providers.py b/python/packages/redis/tests/test_providers.py index 8a73ff3eb7..cc00883837 100644 --- a/python/packages/redis/tests/test_providers.py +++ b/python/packages/redis/tests/test_providers.py @@ -246,19 +246,16 @@ class TestRedisContextProviderHybridQuery: async def test_hybrid_query_uses_linear_alpha( self, mock_index: AsyncMock, - patch_index_from_dict: MagicMock, # noqa: ARG002 + patch_index_from_dict: MagicMock, # noqa: ARG002 - fixture modifies behavior via side effects ): """Ensure HybridQuery is called with linear_alpha parameter for redisvl 0.14.0+.""" - from unittest.mock import AsyncMock as AM - from unittest.mock import MagicMock as MM - from redisvl.utils.vectorize import BaseVectorizer # Create a mock vectorizer that inherits from BaseVectorizer - mock_vectorizer = MM(spec=BaseVectorizer) + mock_vectorizer = MagicMock(spec=BaseVectorizer) mock_vectorizer.dims = 128 mock_vectorizer.dtype = "float32" - mock_vectorizer.aembed = AM(return_value=[0.1] * 128) + mock_vectorizer.aembed = AsyncMock(return_value=[0.1] * 128) mock_index.query = AsyncMock(return_value=[{"content": "test result"}]) @@ -271,7 +268,7 @@ async def test_hybrid_query_uses_linear_alpha( # Call _redis_search with custom alpha with patch("agent_framework_redis._context_provider.HybridQuery") as mock_hybrid_query: - mock_hybrid_query.return_value = MM() + mock_hybrid_query.return_value = MagicMock() await provider._redis_search(text="test query", alpha=0.5) # Verify HybridQuery was called with linear_alpha, not alpha From 192e1ace642409178ba9bafa2ab88a7d314238fc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Feb 2026 09:24:35 +0000 Subject: [PATCH 4/7] Add CHANGELOG entry for redisvl 0.14.0 compatibility fix Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com> --- python/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/CHANGELOG.md b/python/CHANGELOG.md index caa2b40141..9cc6d90212 100644 --- a/python/CHANGELOG.md +++ b/python/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- **agent-framework-redis**: Fix `RedisContextProvider` compatibility with redisvl 0.14.0 by using `linear_alpha` parameter ([#3954](https://github.com/microsoft/agent-framework/pull/3954)) + ## [1.0.0b260212] - 2026-02-12 ### Added From 9c6ad7cdf9b64697e09257fc2878b25920133168 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Feb 2026 16:39:08 +0000 Subject: [PATCH 5/7] Use AggregateHybridQuery instead of HybridQuery for backward compatibility Replace HybridQuery with AggregateHybridQuery to preserve existing functionality that works with older Redis versions. The new HybridQuery in redisvl 0.14.0 requires Redis 8.4.0+ and uses a different API, while AggregateHybridQuery maintains compatibility with the original implementation. Co-authored-by: TaoChenOSU <12570346+TaoChenOSU@users.noreply.github.com> --- python/CHANGELOG.md | 2 +- .../agent_framework_redis/_context_provider.py | 6 +++--- python/packages/redis/tests/test_providers.py | 17 +++++++++-------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/python/CHANGELOG.md b/python/CHANGELOG.md index 9cc6d90212..19560fb3f2 100644 --- a/python/CHANGELOG.md +++ b/python/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- **agent-framework-redis**: Fix `RedisContextProvider` compatibility with redisvl 0.14.0 by using `linear_alpha` parameter ([#3954](https://github.com/microsoft/agent-framework/pull/3954)) +- **agent-framework-redis**: Fix `RedisContextProvider` compatibility with redisvl 0.14.0 by using `AggregateHybridQuery` ([#3954](https://github.com/microsoft/agent-framework/pull/3954)) ## [1.0.0b260212] - 2026-02-12 diff --git a/python/packages/redis/agent_framework_redis/_context_provider.py b/python/packages/redis/agent_framework_redis/_context_provider.py index b4d0500345..ce3747339c 100644 --- a/python/packages/redis/agent_framework_redis/_context_provider.py +++ b/python/packages/redis/agent_framework_redis/_context_provider.py @@ -23,7 +23,7 @@ ServiceInvalidRequestError, ) from redisvl.index import AsyncSearchIndex -from redisvl.query import HybridQuery, TextQuery +from redisvl.query import AggregateHybridQuery, TextQuery from redisvl.query.filter import FilterExpression, Tag from redisvl.utils.token_escaper import TokenEscaper from redisvl.utils.vectorize import BaseVectorizer @@ -366,14 +366,14 @@ async def _redis_search( try: if self.redis_vectorizer and self.vector_field_name: vector = await self.redis_vectorizer.aembed(q) - query = HybridQuery( + query = AggregateHybridQuery( text=q, text_field_name="content", vector=vector, vector_field_name=self.vector_field_name, text_scorer=text_scorer, filter_expression=combined_filter, - linear_alpha=alpha, + alpha=alpha, dtype=self.redis_vectorizer.dtype, num_results=num_results, return_fields=return_fields, diff --git a/python/packages/redis/tests/test_providers.py b/python/packages/redis/tests/test_providers.py index cc00883837..250374f7fc 100644 --- a/python/packages/redis/tests/test_providers.py +++ b/python/packages/redis/tests/test_providers.py @@ -241,14 +241,14 @@ async def test_aenter_returns_self(self, patch_index_from_dict: MagicMock): # n class TestRedisContextProviderHybridQuery: - """Test for HybridQuery parameter compatibility with redisvl 0.14.0.""" + """Test for AggregateHybridQuery parameter compatibility with redisvl 0.14.0.""" - async def test_hybrid_query_uses_linear_alpha( + async def test_aggregate_hybrid_query_uses_alpha( self, mock_index: AsyncMock, patch_index_from_dict: MagicMock, # noqa: ARG002 - fixture modifies behavior via side effects ): - """Ensure HybridQuery is called with linear_alpha parameter for redisvl 0.14.0+.""" + """Ensure AggregateHybridQuery is called with alpha parameter for backward compatibility.""" from redisvl.utils.vectorize import BaseVectorizer # Create a mock vectorizer that inherits from BaseVectorizer @@ -267,16 +267,17 @@ async def test_hybrid_query_uses_linear_alpha( ) # Call _redis_search with custom alpha - with patch("agent_framework_redis._context_provider.HybridQuery") as mock_hybrid_query: + with patch("agent_framework_redis._context_provider.AggregateHybridQuery") as mock_hybrid_query: mock_hybrid_query.return_value = MagicMock() await provider._redis_search(text="test query", alpha=0.5) - # Verify HybridQuery was called with linear_alpha, not alpha + # Verify AggregateHybridQuery was called with alpha parameter mock_hybrid_query.assert_called_once() call_kwargs = mock_hybrid_query.call_args.kwargs - assert "linear_alpha" in call_kwargs - assert call_kwargs["linear_alpha"] == 0.5 - assert "alpha" not in call_kwargs + assert "alpha" in call_kwargs + assert call_kwargs["alpha"] == 0.5 + # linear_alpha should NOT be in the call (that's for the new HybridQuery) + assert "linear_alpha" not in call_kwargs # =========================================================================== From d419407073a1e921d045bc4de68995534979cb22 Mon Sep 17 00:00:00 2001 From: markwallace-microsoft <127216156+markwallace-microsoft@users.noreply.github.com> Date: Thu, 5 Mar 2026 15:29:30 +0000 Subject: [PATCH 6/7] Fix test to use linear_alpha parameter matching _redis_search implementation The test was passing alpha as a keyword argument to _redis_search(), but the method uses linear_alpha to match the redisvl 0.14.0 AggregateHybridQuery API. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- python/packages/redis/tests/test_providers.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/python/packages/redis/tests/test_providers.py b/python/packages/redis/tests/test_providers.py index 584c99c168..2ee7e1c778 100644 --- a/python/packages/redis/tests/test_providers.py +++ b/python/packages/redis/tests/test_providers.py @@ -274,12 +274,12 @@ async def test_aenter_returns_self(self, patch_index_from_dict: MagicMock): # n class TestRedisContextProviderHybridQuery: """Test for AggregateHybridQuery parameter compatibility with redisvl 0.14.0.""" - async def test_aggregate_hybrid_query_uses_alpha( + async def test_aggregate_hybrid_query_uses_linear_alpha( self, mock_index: AsyncMock, patch_index_from_dict: MagicMock, # noqa: ARG002 - fixture modifies behavior via side effects ): - """Ensure AggregateHybridQuery is called with alpha parameter for backward compatibility.""" + """Ensure AggregateHybridQuery is called with linear_alpha parameter for redisvl 0.14.0 compatibility.""" from redisvl.utils.vectorize import BaseVectorizer # Create a mock vectorizer that inherits from BaseVectorizer @@ -297,18 +297,16 @@ async def test_aggregate_hybrid_query_uses_alpha( vector_field_name="embedding", ) - # Call _redis_search with custom alpha + # Call _redis_search with custom linear_alpha with patch("agent_framework_redis._context_provider.AggregateHybridQuery") as mock_hybrid_query: mock_hybrid_query.return_value = MagicMock() - await provider._redis_search(text="test query", alpha=0.5) + await provider._redis_search(text="test query", linear_alpha=0.5) - # Verify AggregateHybridQuery was called with alpha parameter + # Verify AggregateHybridQuery was called with linear_alpha parameter mock_hybrid_query.assert_called_once() call_kwargs = mock_hybrid_query.call_args.kwargs - assert "alpha" in call_kwargs - assert call_kwargs["alpha"] == 0.5 - # linear_alpha should NOT be in the call (that's for the new HybridQuery) - assert "linear_alpha" not in call_kwargs + assert "linear_alpha" in call_kwargs + assert call_kwargs["linear_alpha"] == 0.5 # =========================================================================== From 280454bae71bdb5cd99fed82d95a5f6f4fca3f5b Mon Sep 17 00:00:00 2001 From: markwallace-microsoft <127216156+markwallace-microsoft@users.noreply.github.com> Date: Thu, 5 Mar 2026 17:34:19 +0000 Subject: [PATCH 7/7] Fix pyright error: use alpha parameter matching AggregateHybridQuery API AggregateHybridQuery expects 'alpha', not 'linear_alpha'. Updated the _redis_search method parameter and the test accordingly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../agent_framework_redis/_context_provider.py | 4 ++-- python/packages/redis/tests/test_providers.py | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/python/packages/redis/agent_framework_redis/_context_provider.py b/python/packages/redis/agent_framework_redis/_context_provider.py index 26897adc26..98d5d9917f 100644 --- a/python/packages/redis/agent_framework_redis/_context_provider.py +++ b/python/packages/redis/agent_framework_redis/_context_provider.py @@ -341,7 +341,7 @@ async def _redis_search( filter_expression: Any | None = None, return_fields: list[str] | None = None, num_results: int = 10, - linear_alpha: float = 0.7, + alpha: float = 0.7, ) -> list[dict[str, Any]]: """Runs a text or hybrid vector-text search with optional filters.""" await self._ensure_index() @@ -378,7 +378,7 @@ async def _redis_search( vector_field_name=self.vector_field_name, text_scorer=text_scorer, filter_expression=combined_filter, - linear_alpha=linear_alpha, + alpha=alpha, dtype=self.redis_vectorizer.dtype, # pyright: ignore[reportUnknownMemberType] num_results=num_results, return_fields=return_fields, diff --git a/python/packages/redis/tests/test_providers.py b/python/packages/redis/tests/test_providers.py index 2ee7e1c778..dd0ff51cd8 100644 --- a/python/packages/redis/tests/test_providers.py +++ b/python/packages/redis/tests/test_providers.py @@ -274,12 +274,12 @@ async def test_aenter_returns_self(self, patch_index_from_dict: MagicMock): # n class TestRedisContextProviderHybridQuery: """Test for AggregateHybridQuery parameter compatibility with redisvl 0.14.0.""" - async def test_aggregate_hybrid_query_uses_linear_alpha( + async def test_aggregate_hybrid_query_uses_alpha( self, mock_index: AsyncMock, patch_index_from_dict: MagicMock, # noqa: ARG002 - fixture modifies behavior via side effects ): - """Ensure AggregateHybridQuery is called with linear_alpha parameter for redisvl 0.14.0 compatibility.""" + """Ensure AggregateHybridQuery is called with alpha parameter.""" from redisvl.utils.vectorize import BaseVectorizer # Create a mock vectorizer that inherits from BaseVectorizer @@ -297,16 +297,16 @@ async def test_aggregate_hybrid_query_uses_linear_alpha( vector_field_name="embedding", ) - # Call _redis_search with custom linear_alpha + # Call _redis_search with custom alpha with patch("agent_framework_redis._context_provider.AggregateHybridQuery") as mock_hybrid_query: mock_hybrid_query.return_value = MagicMock() - await provider._redis_search(text="test query", linear_alpha=0.5) + await provider._redis_search(text="test query", alpha=0.5) - # Verify AggregateHybridQuery was called with linear_alpha parameter + # Verify AggregateHybridQuery was called with alpha parameter mock_hybrid_query.assert_called_once() call_kwargs = mock_hybrid_query.call_args.kwargs - assert "linear_alpha" in call_kwargs - assert call_kwargs["linear_alpha"] == 0.5 + assert "alpha" in call_kwargs + assert call_kwargs["alpha"] == 0.5 # ===========================================================================