feat(tools): Add CallableRetrieval for custom retrieval backends#4559
feat(tools): Add CallableRetrieval for custom retrieval backends#4559savula15 wants to merge 1 commit intogoogle:mainfrom
Conversation
Summary of ChangesHello @savula15, 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 introduces the Highlights
🧠 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. Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
9599895 to
5bea4b3
Compare
There was a problem hiding this comment.
Code Review
The addition of CallableRetrieval provides a useful, framework-agnostic way to integrate custom retrieval logic into the ADK. The implementation is well-structured and includes comprehensive unit tests covering various callable types and context passthrough scenarios. I have suggested a refinement to the async dispatch logic to improve performance and robustness with wrapped callables like functools.partial.
Add a new CallableRetrieval class that wraps any user-provided sync or async callable as a BaseRetrievalTool, enabling custom retrieval backends (Elasticsearch, Pinecone, pgvector, etc.) to have first-class retrieval semantics without requiring specific framework dependencies.
5bea4b3 to
51ad6c2
Compare
|
Hi @seanzhou1023 @hangfei This adds a The implementation is small, follows existing patterns closely and introduces zero new dependencies. Happy to iterate on any feedback. Thanks! |
|
Hi @savula15, Thank you for your contribution! We appreciate you taking the time to submit this pull request. |
Add a new CallableRetrieval class that wraps any user-provided sync or async callable as a BaseRetrievalTool, enabling custom retrieval backends (Elasticsearch, Pinecone, pgvector, etc.) to have first-class retrieval semantics without requiring specific framework dependencies.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Testing Plan
Unit Tests:
Added 9 tests in
tests/unittests/tools/retrieval/test_callable_retrieval.py:isinstance(tool, BaseRetrievalTool)isTrue_get_declaration()returns standard{query: string}schematool_contextpassthrough to callable that accepts ittool_contextomission for callable without ittool_context__call__)__call__)Manual End-to-End (E2E) Tests:
N/A. This is a new tool class with no UI or runner changes. Behavior is fully covered by unit tests. Import verified:
Checklist
Additional context
This fills a gap in the retrieval tool family. Existing
BaseRetrievalToolsubclasses (VertexAiRagRetrieval,LlamaIndexRetrieval,FilesRetrieval) all require specific backends.CallableRetrievalis the framework-agnostic entry point, users with custom retrieval logic get proper retrieval semantics (standardizedqueryparameter,isinstanceidentity, graph visualization) without vendor lock-in.Implementation follows the same pattern as
LlamaIndexRetrieval. Zero external dependencies.