#18701: feat(memory-milvus): add Milvus/Zilliz Cloud vector memory provider
size: XL
Cluster:
Memory Database Enhancements
## What
New `memory-milvus` extension — a Milvus-backed vector memory provider for OpenClaw, mirroring the existing `memory-lancedb` plugin. Enables long-term memory storage using self-hosted Milvus or Zilliz Cloud.
## Why
Milvus/Zilliz Cloud offers a managed, scalable vector database alternative to LanceDB. This gives users a cloud-native option for persistent memory without local file storage.
## Changes
- **`extensions/memory-milvus/`** — complete plugin implementation:
- `config.ts` — config schema with env var resolution, SSL auto-detection, strict key validation, configurable `captureMaxChars`
- `index.ts` — MemoryDB with lazy init, AUTOINDEX+COSINE, duplicate detection, prompt injection protection
- `index.test.ts` — 25 tests (22 unit + 3 live E2E against Zilliz Cloud)
- `openclaw.plugin.json` — plugin manifest with config schema and UI hints
- `package.json` — dependencies (`@zilliz/milvus2-sdk-node`, `openai`)
## Key design decisions
- **COSINE metric** used directly (0–1 range, no distance conversion needed)
- **AUTOINDEX** for cross-platform compatibility (local Milvus + Zilliz Cloud)
- **Prompt injection protection**: `looksLikePromptInjection()`, `escapeMemoryForPrompt()`, `formatRelevantMemoriesContext()` — matching lancedb patterns
- **Self-poisoning prevention**: only captures `user` messages, not assistant output
- **`autoCapture` defaults to `false`** (opt-in, matching lancedb)
- **`captureMaxChars`** configurable (100-10000, default 500) for lancedb parity
## Testing
- [x] 22 unit tests pass (config parsing, security functions, shouldCapture, detectCategory, captureMaxChars)
- [x] 3 live E2E tests pass against Zilliz Cloud (store/recall/forget lifecycle)
- [x] `pnpm build` passes
- [x] `pnpm check` passes
## AI Disclosure
Built with Claude Code (AI-assisted). All code reviewed and understood. Fully tested against Zilliz Cloud.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR adds a new `memory-milvus` extension that provides a Milvus/Zilliz Cloud-backed vector memory provider, closely mirroring the existing `memory-lancedb` plugin. The implementation covers config parsing with env var resolution, lazy collection initialization with AUTOINDEX+COSINE, duplicate detection, prompt injection protection, auto-recall/capture hooks, and CLI commands.
- **Bug: Lazy init error recovery is broken** — In `MemoryDB.ensureInitialized()`, if `doInitialize()` fails after `this.client` is assigned (line 71), the `.catch()` handler resets `initPromise` but not `client`. Subsequent calls see `client` as truthy and skip initialization entirely, leaving the plugin silently broken with no retry path.
- Well-aligned with `memory-lancedb` patterns — config schema, security functions (`looksLikePromptInjection`, `escapeMemoryForPrompt`, `formatRelevantMemoriesContext`), tool definitions, lifecycle hooks, and CLI commands are consistent with the reference implementation.
- Good test coverage — 22 unit tests for config, security, and filtering logic, plus 3 live E2E tests gated behind env vars.
- Dependencies are properly structured — plugin-only deps in extension `package.json`, `openclaw` in `devDependencies` with `workspace:*`, `@sinclair/typebox` pinned to match root.
<h3>Confidence Score: 3/5</h3>
- This PR is mostly safe but has a lazy initialization bug that can cause silent failure with no recovery.
- The implementation closely follows the existing memory-lancedb plugin patterns and has good test coverage. However, there is a logic bug in the error recovery path of MemoryDB initialization where this.client is not reset on failure, which would cause the plugin to silently remain broken after any transient initialization error (network issues, Milvus downtime, etc.). This is a real runtime issue that should be fixed before merge.
- Pay close attention to `extensions/memory-milvus/index.ts` — specifically the `ensureInitialized()` / `doInitialize()` error handling around lines 55-75.
<sub>Last reviewed commit: 8d4f36e</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#20771: feat(memory-lancedb): support custom OpenAI-compatible embedding pr...
by marcodelpin · 2026-02-19
72.9%
#19006: feat(memory-lancedb): OpenAI-compatible baseUrl + Ollama provider +...
by martinsen-assistant · 2026-02-17
72.2%
#8795: feat(memory): add Redis-backed long-term memory plugin
by tf-gmail · 2026-02-04
71.6%
#10550: feat(memory-lancedb): local embeddings via node-llama-cpp
by namick · 2026-02-06
70.8%
#17566: memory-lancedb: support local OpenAI-compatible embeddings
by lumenradley · 2026-02-15
70.7%
#18595: feat: native PostgreSQL + pgvector memory backend
by IrriVisionTechnologies · 2026-02-16
70.6%
#17030: feat(memory-lancedb): support Ollama and OpenAI-compatible embeddin...
by nightfullstar · 2026-02-15
70.3%
#22692: fix(memory-lancedb): [P1] add missing runtime deps — plugin broken ...
by mahsumaktas · 2026-02-21
69.5%
#16669: feat(memory-lancedb): add memory_search/memory_get compatibility re...
by ciberponk · 2026-02-15
69.2%
#20338: feat: add daedalus-memory plugin — trust-gradient memory with tri-c...
by CmdrFALCO · 2026-02-18
68.9%