Skip to content

Conversation

@nkanu17
Copy link

@nkanu17 nkanu17 commented Jan 7, 2026

Add RedisVL Search Tools for Knowledge Base Retrieval

This PR adds four RedisVL-based search tools as optional dependencies, enabling agents to perform vector, text, hybrid, and range searches against Redis-based knowledge bases. This provides a self-hosted alternative to Google Cloud retrieval tools (Vertex AI Search, Discovery Engine).

Related to issue #42

Changes

New Tools (src/google/adk_community/tools/redis/)

Tool Search Type Use Case
RedisVectorSearchTool KNN vector similarity Semantic/conceptual queries
RedisTextSearchTool BM25 full-text Exact terms, acronyms, API names
RedisHybridSearchTool Vector + BM25 combined Best of both worlds
RedisRangeSearchTool Distance threshold Exhaustive retrieval, quality filtering

Dependencies (pyproject.toml)

[project.optional-dependencies]
redis-vl = [
    "redisvl>=0.13.2",
    "nltk>=3.8.0",
    "sentence-transformers>=2.2.0",
]

Installation:

pip install google-adk-community[redis-vl]

Sample Agent

Added contributing/samples/redis_vl_search/ with a complete example demonstrating all four search tools.

Requirements for HybridQuery

RedisHybridSearchTool uses Redis's native FT.HYBRID command and requires:

  • Redis >= 8.4.0
  • redis-py >= 7.1.0

Related Issues

Testing

Unit Tests

pytest tests/unittests/tools/redis/ -v

All tests pass with mocked RedisVL dependencies.

Manual E2E Testing

Screenshots using adk web:
Screenshot 2025-12-22 at 2 51 35 PM

Screenshot 2025-12-22 at 2 51 56 PM Screenshot 2026-01-09 at 7 48 17 PM

Additional Notes

  • Async support — Works with both SearchIndex and AsyncSearchIndex
  • All tools extend BaseTool with proper FunctionDeclaration for LLM integration

- Add RedisVectorSearchTool for KNN semantic search
- Add RedisTextSearchTool for BM25 keyword search
- Add RedisRangeSearchTool for threshold-based search
- Add RedisHybridSearchTool for combined vector + text search
- Add redis-vl optional dependency (redisvl, nltk, sentence-transformers)
- Add sample agent demonstrating all search tools
- Add unit tests for all tools
- Add vector_param_name, yield_text_score_as, vector_search_method
- Add knn_ef_runtime, range_radius, range_epsilon, yield_vsim_score_as
- Add yield_combined_score_as for score output control
- Document Redis >= 8.4.0 and redis-py >= 7.1.0 requirements
@google-cla
Copy link

google-cla bot commented Jan 7, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @nkanu17, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the capabilities of the ADK by integrating RedisVL-based search tools. It provides a robust, self-hosted alternative for knowledge base retrieval, offering various search modalities like vector, text, hybrid, and range searches. This enhancement allows agents to interact with Redis-backed knowledge bases, catering to developers who require more control over their infrastructure and complementing existing Google Cloud retrieval options.

Highlights

  • New RedisVL Search Tools: Introduced four new RedisVL-based search tools: RedisVectorSearchTool (KNN vector similarity), RedisTextSearchTool (BM25 full-text), RedisHybridSearchTool (vector + BM25 combined), and RedisRangeSearchTool (distance threshold). These tools enable agents to perform various types of searches against Redis-based knowledge bases.
  • Optional Dependency: Added 'redis-vl' as an optional dependency to pyproject.toml, allowing users to opt-in to Redis search capabilities without increasing the core library's footprint. This aligns with the community repository's philosophy of keeping the core ADK stable and lightweight.
  • Comprehensive Sample Agent: Included a new sample agent (contributing/samples/redis_vl_search/) that demonstrates the setup, data loading, and practical usage of all four new Redis search tools, complete with example queries and customization options.
  • Lazy Loading Implementation: Implemented lazy loading for all Redis tools within src/google/adk_community/tools/__init__.py to ensure that 'redisvl' and its related dependencies are only imported when a Redis tool is explicitly used, providing helpful error messages if not installed.
  • Hybrid Search Requirements: The RedisHybridSearchTool leverages Redis's native FT.HYBRID command, requiring Redis version 8.4.0 or higher and redis-py version 7.1.0 or higher for full functionality.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive set of Redis search tools, enabling vector, text, hybrid, and range searches. The implementation is well-structured, with a base class for vector-based tools, separate handling for text search, and a clever lazy-loading mechanism for the optional dependencies. The accompanying sample agent and documentation are excellent and provide clear guidance for users.

My review includes a critical fix for the sample agent to ensure it runs correctly, along with a few medium-severity suggestions to improve design consistency, reduce code duplication, and refine the lazy-loading implementation for better performance and maintainability. Overall, this is a high-quality contribution that significantly enhances the library's capabilities.

Address PR google#43 code review feedback from Gemini Code Assist.
Update model name from gemini-2.0-flash-001 to gemini-2.5-flash in:
- Sample agent (agent.py)
- Tool docstrings (vector, text, hybrid, range search tools)
- GitHub issue document
- Split BaseRedisSearchTool into shared base + VectorizedSearchTool
- BaseRedisSearchTool now contains shared logic (_execute_query, _run_search)
- VectorizedSearchTool requires vectorizer (no longer Optional)
- RedisTextSearchTool now extends BaseRedisSearchTool (inherits shared logic)
- Vector-based tools extend VectorizedSearchTool

This addresses PR review feedback:
- 2b: Vectorizer is now required in VectorizedSearchTool (fail-fast)
- 2c: Eliminates ~14 lines of duplicated code via inheritance
@nkanu17
Copy link
Author

nkanu17 commented Jan 8, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is an excellent pull request that adds significant value by providing self-hosted Redis-based retrieval tools as an alternative to cloud-based solutions. The code quality is high, with well-structured, documented, and tested tool classes that thoughtfully expose the underlying redisvl library's capabilities. The use of base classes and lazy loading for optional dependencies is well-executed. I have a couple of minor suggestions to improve performance in the sample data loading script and enhance maintainability in one of the tool classes. Overall, a very strong contribution.

Add configuration classes to group query-specific parameters:
- RedisVectorQueryConfig: 15 parameters for vector similarity search
- RedisRangeQueryConfig: 11 parameters for range-based search
- RedisHybridQueryConfig: 22 parameters for hybrid text+vector search
- RedisTextQueryConfig: 8 parameters for full-text search

Each config class includes:
- Pydantic validation with Field() constraints
- ConfigDict(extra='forbid') to catch typos
- to_query_kwargs() method for query construction
- Comprehensive docstrings for each parameter
Refactor all four Redis search tools to accept config objects:
- RedisVectorSearchTool: 22 params -> 7 params
- RedisHybridSearchTool: 26 params -> 7 params
- RedisRangeSearchTool: 14 params -> 7 params
- RedisTextSearchTool: 12 params -> 6 params

Benefits:
- Reduces constructor parameter explosion
- Groups query-specific parameters logically
- Follows BigQueryToolConfig and OpenMemoryServiceConfig patterns
- Enables Pydantic validation of parameters
Add exports for all Redis config classes:
- RedisVectorQueryConfig
- RedisHybridQueryConfig
- RedisRangeQueryConfig
- RedisTextQueryConfig

Supports lazy loading pattern for optional redisvl dependency.
Update all Redis search tool tests to use config objects:
- test_vector_search_tool.py
- test_hybrid_search_tool.py
- test_range_search_tool.py
- test_text_search_tool.py

Tests now verify config object properties instead of direct attributes.
Update sample agent and README to use config objects:
- RedisVectorQueryConfig for semantic_search
- RedisTextQueryConfig for keyword_search
- RedisRangeQueryConfig for range_search

README examples updated to show config-based usage pattern.
- Add RedisAggregatedHybridQueryConfig for older RedisVL versions (<0.13.0)
- RedisHybridSearchTool now auto-detects RedisVL version and uses appropriate query class
- Native HybridQuery (FT.HYBRID) used for RedisVL >= 0.13.0, Redis >= 8.4.0
- AggregateHybridQuery (FT.AGGREGATE) used for older versions
- Emit DeprecationWarning when using aggregate config on newer versions
- Raise ValueError when using native config on older versions
- Use packaging.version.parse() for version comparison (aligns with ADK patterns)
- Update tests to cover both code paths and version detection
…hybrid support

- Add _MIN_REDIS_SERVER_VERSION constant (8.4.0) for FT.HYBRID command
- Add _get_redis_server_version() to retrieve Redis server version from index client
- Update _supports_native_hybrid() to check both redisvl >= 0.13.0 AND Redis >= 8.4.0
- Add proper logging: debug for version mismatches, warning for parsing errors
- Handle edge cases: None client, connection errors, version parsing failures
- Update error messages to include both version numbers
- Add comprehensive tests for Redis server version detection
@nkanu17 nkanu17 marked this pull request as ready for review January 20, 2026 16:03
@nkanu17
Copy link
Author

nkanu17 commented Jan 20, 2026

@hangfei @koverholt
can you take a look at this pr? Would love thoughts from you and the community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add RedisVL Search Tools for Knowledge Base Retrieval

1 participant