ADK Milvus
Milvus integrations for Google Agent Development Kit (ADK).
This package provides:
MilvusMemoryService: a Milvus-backed ADKBaseMemoryServicefor cross-session memory.MilvusVectorStoreandMilvusToolset: a Milvus-backed retrieval toolset for RAG-style agent tools.
The same configuration shape supports Milvus Lite, Milvus server, and Zilliz Cloud. New projects default to Milvus Lite, so local development requires no separate database service.
Installation
Install with pip:
pip install adk-milvus
Install with uv:
uv add adk-milvus
Configuration
Use MILVUS_URI and MILVUS_TOKEN for all deployment modes:
# Milvus Lite
export MILVUS_URI="./adk_milvus.db"
# Milvus server
export MILVUS_URI="http://localhost:19530"
# Zilliz Cloud
export MILVUS_URI="https://your-endpoint.api.gcp-us-west1.zillizcloud.com"
export MILVUS_TOKEN="your-token"
MILVUS_TOKEN is only needed for authenticated deployments such as Zilliz
Cloud. If you use a non-default Milvus database, set MILVUS_DB_NAME.
Memory Service
MilvusMemoryService accepts any embedding function that returns one vector per
input text. It implements ADK's
BaseMemoryService, so it
can be passed to an ADK Runner or used directly with add_events_to_memory()
/ search_memory().
from adk_milvus import MilvusMemoryService
memory_service = MilvusMemoryService(
embedding_function=embedding_function,
dimension=1536,
)
Run the complete OpenAI embedding example:
export OPENAI_API_KEY="..."
python examples/memory_service_openai.py
The memory service scopes search by app_name and user_id, so one user
cannot retrieve another user's memories through this service.
Retrieval Toolset
MilvusVectorStore stores indexed text. MilvusToolset exposes the
milvus_similarity_search tool that an
ADK agent can call.
from adk_milvus import MilvusToolset
from adk_milvus import MilvusVectorStore
from adk_milvus import MilvusVectorStoreSettings
vector_store = MilvusVectorStore(
embedding_function=embedding_function,
settings=MilvusVectorStoreSettings(
collection_name="adk_rag",
dimension=1536,
),
)
vector_store.add_texts(
[
"Milvus Lite is useful for local RAG development.",
"Zilliz Cloud provides managed Milvus for production workloads.",
],
metadatas=[
{"source": "milvus-lite"},
{"source": "zilliz-cloud"},
],
)
toolset = MilvusToolset(vector_store=vector_store)
Run the complete OpenAI embedding example:
export OPENAI_API_KEY="..."
python examples/retrieval_toolset_openai.py
The retrieval tool returns:
{
"status": "SUCCESS",
"rows": [
{
"id": "...",
"content": "...",
"source": "...",
"metadata": {...},
"distance": 0.12,
}
],
}
End-to-End Usage
The snippets below assume embedding_function returns 1536-dimensional vectors.
Case 1: Cross-session memory
Use MilvusMemoryService when the agent needs to remember user-specific context
across sessions:
import asyncio
from adk_milvus import MilvusMemoryService
from google.adk.agents import Agent
from google.adk.events.event import Event
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.genai import types
async def main():
app_name = "milvus_memory_app"
memory_service = MilvusMemoryService(
embedding_function=embedding_function,
dimension=1536,
collection_name="adk_memory",
consistency_level="Strong",
)
runner = Runner(
app_name=app_name,
agent=Agent(
name="memory_agent",
model="gemini-2.5-flash",
instruction="Use memory when it is relevant to the user's request.",
),
session_service=InMemorySessionService(),
memory_service=memory_service,
)
try:
await memory_service.add_events_to_memory(
app_name=app_name,
user_id="user-1",
session_id="session-1",
events=[
Event(
id="event-1",
invocation_id="invocation-1",
author="user",
timestamp=12345,
content=types.Content(
parts=[
types.Part(
text="The user prefers Milvus for vector memory."
)
]
),
)
],
)
result = await memory_service.search_memory(
app_name=app_name,
user_id="user-1",
query="database preference",
)
print(result.memories[0].content.parts[0].text)
finally:
await memory_service.close()
asyncio.run(main())
Case 2: Knowledge-base retrieval
Use MilvusToolset when the agent needs a retrieval tool over external
documents or product knowledge:
import asyncio
from adk_milvus import MilvusToolset, MilvusVectorStore, MilvusVectorStoreSettings
from google.adk.agents import Agent
async def main():
vector_store = MilvusVectorStore(
embedding_function=embedding_function,
settings=MilvusVectorStoreSettings(
collection_name="adk_rag",
dimension=1536,
consistency_level="Strong",
),
)
toolset = MilvusToolset(vector_store=vector_store)
try:
await vector_store.add_texts_async(
[
"Milvus Lite is useful for local RAG development.",
"Zilliz Cloud provides managed Milvus for production workloads.",
],
metadatas=[
{"source": "milvus-lite"},
{"source": "zilliz-cloud"},
],
)
tools = await toolset.get_tools_with_prefix()
agent = Agent(
name="rag_agent",
model="gemini-2.5-flash",
instruction="Use retrieval tools before answering knowledge questions.",
tools=tools,
)
result = await tools[0].run_async(
args={"query": "managed Milvus for production"},
tool_context=None,
)
print(result["rows"][0]["content"])
finally:
await toolset.close()
asyncio.run(main())
See examples/memory_service_openai.py and
examples/retrieval_toolset_openai.py for runnable scripts that exercise each
component.
Contributing
See CONTRIBUTING.md for local development, testing, and release checks.
Metadata
Release files for adk-milvus 0.1.0
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_milvus-0.1.0.tar.gz | 160.4 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| adk_milvus-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 183.9 kB
Release files / adk_milvus-0.1.0.tar.gz
| Download URL | adk_milvus-0.1.0.tar.gz |
|---|---|
| Size | 160.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e469a87a2490b52aa68100352748fcc55c5a1f88f6468a0a25e08309cc584fa1
|
|
BLAKE2b-256 checksum How to use checksums |
baf2dd83ed72ced5b3b5838bad5f1c278b552fefecff7ed371434bd8c9c2b4bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 15, 2026.
Transparency logRelease files / adk_milvus-0.1.0-py3-none-any.whl
| Download URL | adk_milvus-0.1.0-py3-none-any.whl |
|---|---|
| Size | 23.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7cf5bbe982b16cc3476f32ddf2f41b129075682465668357dc95964b5d9fdbfd
|
|
BLAKE2b-256 checksum How to use checksums |
a3dbef39ddf68a3f3426971a4fa2dd9a140cf08736e986aad62ffd5ce0d5ca19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 15, 2026.
Transparency logSecurity for adk-milvus 0.1.0
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_milvus-0.1.0.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 Jul 15, 2026.
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.