← Back to PRs

#18701: feat(memory-milvus): add Milvus/Zilliz Cloud vector memory provider

by supmo668 open 2026-02-17 00:13 View on GitHub →
size: XL
## 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