Langchain Retrievers for Google ADK
Install
uv add adk-retrieval
Usage
This library exposes LangchainRetrievalTool which is a Google ADK tool.
The tool expects an instance of langchain retriever (See - https://docs.langchain.com/oss/python/integrations/retrievers)
By default LangchainRetrievalTool returns str which is the page_content of the first langchain Document. If that satisfies your needs then
look at the basic example below.
In some cases, you would want to post-process the documents and convert them to str as you see fit. In that case, you can either write your own Retriever or use the callback. See the little sophisticated example below.
Basic example
Below is a basic example that shows how to use a retriever from langchain in Google ADK agent.
The first (langchain) document's page_content is returned by LangchainRetrievalTool irrespective of any top_k you may have used in your langchain Retriever.
import wikipedia
from google.adk.agents import LlmAgent
from langchain_community.retrievers import WikipediaRetriever
from adk_retrieval import LangchainRetrievalTool
root_agent = LlmAgent(
name="adk_wikipedia_agent",
description="Agent for summarizing Wikipedia articles.",
instruction="""You are a specialized search & summarizer agent for Wikipedia articles.
""",
model="gemini-2.5-flash",
tools=[
LangchainRetrievalTool(
name="wikipedia_retrieval_tool",
description="Tool for retrieving Wikipedia articles based on user queries.",
retriever=WikipediaRetriever(wiki_client=wikipedia),
)
],
)
A little sophisticated example
This example shows how you provide your own callback that takes all the documents returned by your langchain Retriever and convert them into a single string.
import wikipedia
from google.adk.agents import LlmAgent
from langchain_community.retrievers import WikipediaRetriever
from langchain_core.documents import Document
from adk_retrieval import LangchainRetrievalTool
# an example post-processing function that combines multiple documents into a single string
async def post_process(docs: list[Document]) -> str:
sources = []
for index, doc in enumerate(docs):
sources.append(f"Source {index + 1}:\n{doc.page_content}\n")
return "\n\n".join(sources)
root_agent = LlmAgent(
name="wiki_sophisticated",
description="Agent for summarizing Wikipedia articles.",
instruction="""You are a specialized search & summarizer agent for Wikipedia articles.
""",
model="gemini-2.5-flash",
tools=[
LangchainRetrievalTool(
name="wikipedia_retrieval_tool",
description="Tool for retrieving Wikipedia articles based on user queries.",
retriever=WikipediaRetriever(wiki_client=wikipedia, top_k_results=3),
post_process=post_process,
)
],
)
Examples
Open this repository in devcontainer and all dependencies will be setup for you
# Run examples using the built-in `adk web`
uv run adk web examples
Metadata
Release files for adk-retrieval 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| adk_retrieval-0.0.2.tar.gz | 224.9 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| adk_retrieval-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 232.4 kB
Release files / adk_retrieval-0.0.2.tar.gz
| Download URL | adk_retrieval-0.0.2.tar.gz |
|---|---|
| Size | 224.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d8849d739771a217f5aab6c2ae1cb13627951b417782298290a29603a54952e
|
|
BLAKE2b-256 checksum How to use checksums |
007f3103a169b91cbab94ee962af7faa5dcc0c4aec457d5204f8a8ac31512493
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2025.
Transparency logRelease files / adk_retrieval-0.0.2-py3-none-any.whl
| Download URL | adk_retrieval-0.0.2-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6aa9ee3ca9b1df40659ce21e0d8610409648e1997088c460f25eb95270f1a64e
|
|
BLAKE2b-256 checksum How to use checksums |
24da0b7ca23c09e34e5179c64c966a12f59b9994b929f728ef44f612241f4481
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2025.
Transparency logSecurity for adk-retrieval 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for adk_retrieval-0.0.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.