-
Notifications
You must be signed in to change notification settings - Fork 36.7k
Description
Summary
When memory.backend = "qmd" is configured, OpenClaw creates and manages its own QMD index at ~/.openclaw/agents/main/qmd/xdg-cache/qmd/index.sqlite with proper XDG isolation. However, if the standalone qmd CLI has previously added collections to the same index (or if collections leak in from a shared config), memory_search queries will search all collections β not just the ones OpenClaw manages.
Current Behavior
- OpenClaw's config (
memory.qmd.paths: []) resolves to onlymemory-root,memory-alt,memory-dir, andsessionscollections - But the QMD index file can contain additional collections (e.g.,
meetings,obsidian,projects) that were added externally QmdMemoryManager.search()runsqmd query <text> --json -n <limit>with no collection filter (-cflag)- This means
memory_searchreturns results from all collections in the index, including ones OpenClaw didn't create - With a large index (286+ files, 1900+ embeddings), the
qmd querycommand frequently times out at the 4s default, falling back to the builtin SQLite backend
Expected Behavior
memory_search should only return results from collections that OpenClaw manages (default memory collections + configured paths + sessions).
Suggested Fix
Two complementary approaches:
1. Scope search queries to managed collections
In QmdMemoryManager.search(), pass -c flags for each managed collection, or use a combined collection filter if QMD supports it.
2. Clean up foreign collections on boot
In ensureCollections(), after ensuring managed collections exist, remove any collections from the index that are NOT in the resolved config. This prevents stale/foreign collections from accumulating.
Environment
- OpenClaw: 2026.2.3-1
- QMD: standalone CLI (bun-based, uses SQLite + sqlite-vec)
- OS: macOS (Darwin arm64)
Reproduction
- Install standalone
qmdand add collections:qmd collection add /path/to/docs --name extra-docs - Configure OpenClaw with
memory.backend = "qmd"andmemory.qmd.paths: [] - Run
memory_searchfor a topic that exists in the external collection - Results from
extra-docswill appear even though OpenClaw didn't configure it
The issue occurs because both the standalone QMD and OpenClaw's QMD instance can share the same index file (or collections can be manually added to the OpenClaw-managed index).