Skip to content

Commit 9c6ad7c

Browse files
CopilotTaoChenOSU
andcommitted
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 <[email protected]>
1 parent 192e1ac commit 9c6ad7c

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

python/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Fixed
1111

12-
- **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))
12+
- **agent-framework-redis**: Fix `RedisContextProvider` compatibility with redisvl 0.14.0 by using `AggregateHybridQuery` ([#3954](https://github.com/microsoft/agent-framework/pull/3954))
1313

1414
## [1.0.0b260212] - 2026-02-12
1515

python/packages/redis/agent_framework_redis/_context_provider.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
ServiceInvalidRequestError,
2424
)
2525
from redisvl.index import AsyncSearchIndex
26-
from redisvl.query import HybridQuery, TextQuery
26+
from redisvl.query import AggregateHybridQuery, TextQuery
2727
from redisvl.query.filter import FilterExpression, Tag
2828
from redisvl.utils.token_escaper import TokenEscaper
2929
from redisvl.utils.vectorize import BaseVectorizer
@@ -366,14 +366,14 @@ async def _redis_search(
366366
try:
367367
if self.redis_vectorizer and self.vector_field_name:
368368
vector = await self.redis_vectorizer.aembed(q)
369-
query = HybridQuery(
369+
query = AggregateHybridQuery(
370370
text=q,
371371
text_field_name="content",
372372
vector=vector,
373373
vector_field_name=self.vector_field_name,
374374
text_scorer=text_scorer,
375375
filter_expression=combined_filter,
376-
linear_alpha=alpha,
376+
alpha=alpha,
377377
dtype=self.redis_vectorizer.dtype,
378378
num_results=num_results,
379379
return_fields=return_fields,

python/packages/redis/tests/test_providers.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,14 @@ async def test_aenter_returns_self(self, patch_index_from_dict: MagicMock): # n
241241

242242

243243
class TestRedisContextProviderHybridQuery:
244-
"""Test for HybridQuery parameter compatibility with redisvl 0.14.0."""
244+
"""Test for AggregateHybridQuery parameter compatibility with redisvl 0.14.0."""
245245

246-
async def test_hybrid_query_uses_linear_alpha(
246+
async def test_aggregate_hybrid_query_uses_alpha(
247247
self,
248248
mock_index: AsyncMock,
249249
patch_index_from_dict: MagicMock, # noqa: ARG002 - fixture modifies behavior via side effects
250250
):
251-
"""Ensure HybridQuery is called with linear_alpha parameter for redisvl 0.14.0+."""
251+
"""Ensure AggregateHybridQuery is called with alpha parameter for backward compatibility."""
252252
from redisvl.utils.vectorize import BaseVectorizer
253253

254254
# Create a mock vectorizer that inherits from BaseVectorizer
@@ -267,16 +267,17 @@ async def test_hybrid_query_uses_linear_alpha(
267267
)
268268

269269
# Call _redis_search with custom alpha
270-
with patch("agent_framework_redis._context_provider.HybridQuery") as mock_hybrid_query:
270+
with patch("agent_framework_redis._context_provider.AggregateHybridQuery") as mock_hybrid_query:
271271
mock_hybrid_query.return_value = MagicMock()
272272
await provider._redis_search(text="test query", alpha=0.5)
273273

274-
# Verify HybridQuery was called with linear_alpha, not alpha
274+
# Verify AggregateHybridQuery was called with alpha parameter
275275
mock_hybrid_query.assert_called_once()
276276
call_kwargs = mock_hybrid_query.call_args.kwargs
277-
assert "linear_alpha" in call_kwargs
278-
assert call_kwargs["linear_alpha"] == 0.5
279-
assert "alpha" not in call_kwargs
277+
assert "alpha" in call_kwargs
278+
assert call_kwargs["alpha"] == 0.5
279+
# linear_alpha should NOT be in the call (that's for the new HybridQuery)
280+
assert "linear_alpha" not in call_kwargs
280281

281282

282283
# ===========================================================================

0 commit comments

Comments
 (0)