Skip to content

Python: Fix RedisContextProvider for redisvl 0.14.0 by using AggregateHybridQuery#3954

Open
Copilot wants to merge 5 commits intomainfrom
copilot/fix-redis-search-alpha-parameter
Open

Python: Fix RedisContextProvider for redisvl 0.14.0 by using AggregateHybridQuery#3954
Copilot wants to merge 5 commits intomainfrom
copilot/fix-redis-search-alpha-parameter

Conversation

Copy link
Contributor

Copilot AI commented Feb 16, 2026

Motivation and Context

redisvl 0.14.0 introduced a breaking change where HybridQuery was replaced with a new implementation requiring Redis 8.4.0+. The original code used HybridQuery, which caused compatibility issues:

TypeError: HybridQuery.__init__() got an unexpected keyword argument 'alpha'

Description

Core Fix

  • Replaced HybridQuery with AggregateHybridQuery in RedisContextProvider._redis_search() to maintain backward compatibility with older Redis versions
  • AggregateHybridQuery preserves the original aggregation pipeline-based hybrid search functionality that works with Redis versions prior to 8.4.0
  • Continues to use the alpha parameter as expected by AggregateHybridQuery

Why AggregateHybridQuery instead of the new HybridQuery?

  • The new HybridQuery in redisvl 0.14.0+ uses Redis's native FT.HYBRID command, which requires Redis 8.4.0+
  • AggregateHybridQuery uses the aggregation pipeline approach, maintaining compatibility with existing Redis deployments
  • This preserves the original functionality without requiring Redis version upgrades

Testing

  • Added regression test verifying that AggregateHybridQuery is used with the correct alpha parameter

Documentation

  • Added CHANGELOG entry documenting the fix

The change replaces the query class and maintains the original parameter:

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,
    alpha=alpha,  # Using alpha parameter as expected by AggregateHybridQuery
    dtype=self.redis_vectorizer.dtype,
    num_results=num_results,
    return_fields=return_fields,
    stopwords=None,
)

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.
Original prompt

This section details on the original issue you should resolve

<issue_title>Python: RedisProvider._redis_search() incompatible with redisvl 0.14.0: 'alpha' renamed to 'linear_alpha' in HybridQuery</issue_title>
<issue_description>## Bug Report

Description

RedisProvider._redis_search() passes alpha to redisvl.query.HybridQuery, but redisvl v0.14.0 renamed this parameter to linear_alpha.

Error

TypeError: HybridQuery.__init__() got an unexpected keyword argument 'alpha'

Wrapped as:

agent_framework.exceptions.ServiceInvalidRequestError: Redis text search failed: HybridQuery.__init__() got an unexpected keyword argument 'alpha'

Location

agent_framework_redis/_provider.py, in _redis_search():

query = HybridQuery(
    text=q,
    text_field_name="content",
    vector=vector,
    vector_field_name=self.vector_field_name,
    text_scorer=text_scorer,
    filter_expression=combined_filter,
    alpha=alpha,  # <-- this parameter no longer exists in redisvl 0.14.0
    dtype=self.redis_vectorizer.dtype,
    num_results=num_results,
    return_fields=return_fields,
    stopwords=None,
)

Expected Fix

Replace alpha=alpha with linear_alpha=alpha to match the redisvl 0.14.0 API:

query = HybridQuery(
    ...
    linear_alpha=alpha,
    ...
)

The redisvl 0.14.0 HybridQuery signature expects linear_alpha: float = 0.3 instead of alpha.

Steps to Reproduce

  1. Install agent-framework-redis (at commit 98cd72839e) which pulls redisvl>=0.14.0
  2. Create a RedisProvider with a vectorizer configured (e.g., AzureOpenAITextVectorizer)
  3. Run an agent with the provider — the first invoking() call triggers _redis_search() which fails

Environment

  • agent-framework-redis at commit 98cd72839e
  • redisvl==0.14.0
  • Python 3.12</issue_description>

<agent_instructions>Fix the bug described in this issue. Run the pre-commit hooks and fix any errors. Add a unit test to prevent regression.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…0 compatibility

Co-authored-by: markwallace-microsoft <127216156+markwallace-microsoft@users.noreply.github.com>
…ment

Co-authored-by: markwallace-microsoft <127216156+markwallace-microsoft@users.noreply.github.com>
@github-actions github-actions bot changed the title [WIP] Fix RedisProvider._redis_search() incompatible with redisvl 0.14.0 Python: [WIP] Fix RedisProvider._redis_search() incompatible with redisvl 0.14.0 Feb 16, 2026
Copilot AI changed the title Python: [WIP] Fix RedisProvider._redis_search() incompatible with redisvl 0.14.0 Python: Fix RedisContextProvider for redisvl 0.14.0 HybridQuery API change Feb 16, 2026
@markwallace-microsoft markwallace-microsoft marked this pull request as ready for review February 16, 2026 14:44
Copilot AI review requested due to automatic review settings February 16, 2026 14:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a compatibility issue with redisvl 0.14.0, which renamed the HybridQuery constructor parameter from alpha to linear_alpha. The change prevents a TypeError when Redis hybrid search is used with a vectorizer configured.

Changes:

  • Updated RedisContextProvider._redis_search() to pass linear_alpha instead of alpha to HybridQuery
  • Added regression test to verify the correct parameter name is used

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
python/packages/redis/agent_framework_redis/_context_provider.py Changed parameter name from alpha to linear_alpha in HybridQuery instantiation (line 376)
python/packages/redis/tests/test_providers.py Added test class TestRedisContextProviderHybridQuery with test verifying linear_alpha parameter usage

@vishal-bala
Copy link

vishal-bala commented Feb 16, 2026

Hey there! I'm with the team at Redis that maintains RedisVL - since redisvl==0.13.0 there have been a couple of options for hybrid search, which is where the bug here originally stemmed from.

The integration imports and uses the HybridQuery class, which now points to Redis's native hybrid search functionality (available only with Redis 8.4.0+). To preserve the existing functionality as it previously was in this integration, the simpler fix would be to replace

from redisvl.query import HybridQuery

with

from redisvl.query import AggregateHybridQuery

and associated usages. The syntax that this integration currently expects is the syntax for AggregateHybridQuery and not the latest HybridQuery. Alternatively, setting a version constraint for redisvl<=0.13.0 would also work.

Switching the linear_alpha parameter name is also a gotcha because with the new Redis FT.HYBRID syntax (which HybridQuery wraps), alpha refers to the weight of the text query while in the original syntax it refers to the weight of the vector query (super confusing, I know).

Thanks for taking on the fix for this integration! Let me know if that context is helpful or if I can clarify anything.

text_scorer=text_scorer,
filter_expression=combined_filter,
alpha=alpha,
linear_alpha=alpha,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a misleading fix - see my comment on the main PR. As of redisvl>=0.13.0, the HybridQuery class wraps the native Redis FT.HYBRID search command. For this command, alpha refers to the weight of the text query in the score combination.

Prior to redisvl==0.13.0, the implementation used the FT.AGGREGATE operation, and RedisVL defined alpha as the weight of the vector query in the score combination. This legacy approach is still accessible via from redisvl.query import AggregateHybridQuery, which is what the syntax in this project is expecting.

Without care, simply switching alpha to linear_alpha would actually invert the weighting of the score components for existing implementations.

@eavanvalkenburg
Copy link
Member

@copilot please review @vishal-bala comments and adjust accordingly. @vishal-bala many thanks for jumping in here!

Copy link
Contributor Author

Copilot AI commented Feb 17, 2026

@copilot please review @vishal-bala comments and adjust accordingly. @vishal-bala many thanks for jumping in here!

I don't see any comments from @vishal-bala in the current thread. Could you please share or point me to the specific feedback that needs to be addressed?

@eavanvalkenburg
Copy link
Member

@copilot this one #3954 (comment) and #3954 (comment)

Co-authored-by: eavanvalkenburg <13749212+eavanvalkenburg@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 17, 2026

@copilot this one #3954 (comment) and #3954 (comment)

Added CHANGELOG entry for the fix in commit 192e1ac.

@markwallace-microsoft markwallace-microsoft added the documentation Improvements or additions to documentation label Feb 17, 2026
@vishal-bala
Copy link

@copilot Here is the gist of my recommended changes:

The integration imports and uses the HybridQuery class, which points to Redis's native hybrid search functionality (since redisvl>=0.13.0; available only with Redis 8.4.0+). To preserve the existing functionality as it previously was in this integration, the simplest fix would be to replace

from redisvl.query import HybridQuery

with

from redisvl.query import AggregateHybridQuery

and to update its usages accordingly.

@vishal-bala
Copy link

@eavanvalkenburg Happy to help! It looks like Copilot doesn't see or respond to my comments - feel free to copy-paste or paraphrase them if you need to instruct Copilot to take action 😄

@TaoChenOSU
Copy link
Contributor

@copilot Here is the gist of my recommended changes:

The integration imports and uses the HybridQuery class, which points to Redis's native hybrid search functionality (since redisvl>=0.13.0; available only with Redis 8.4.0+). To preserve the existing functionality as it previously was in this integration, the simplest fix would be to replace

from redisvl.query import HybridQuery

with

from redisvl.query import AggregateHybridQuery

and to update its usages accordingly.

@copilot Implement and test this recommended changes

…ility

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>
Copy link
Contributor Author

Copilot AI commented Feb 17, 2026

@copilot Here is the gist of my recommended changes:

The integration imports and uses the HybridQuery class, which points to Redis's native hybrid search functionality (since redisvl>=0.13....

Implemented the recommended changes in commit 9c6ad7c. Replaced HybridQuery with AggregateHybridQuery to maintain backward compatibility with older Redis versions. The test now verifies that AggregateHybridQuery is used with the alpha parameter as expected.

Copilot AI changed the title Python: Fix RedisContextProvider for redisvl 0.14.0 HybridQuery API change Python: Fix RedisContextProvider for redisvl 0.14.0 by using AggregateHybridQuery Feb 17, 2026
Copilot AI requested a review from TaoChenOSU February 17, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: RedisProvider._redis_search() incompatible with redisvl 0.14.0: 'alpha' renamed to 'linear_alpha' in HybridQuery

5 participants