Skip to content

memory_search with qmd backend: collection name mismatch causes empty results #9854

@BBleae

Description

@BBleae

Summary

When using the qmd backend for memory_search, search results may be silently dropped if the collection names in the qmd database don't match what OpenClaw expects.

Environment

  • OpenClaw version: 2026.2.3-1
  • qmd version: 0.7.x (external CLI)
  • OS: macOS (arm64)

Steps to Reproduce

  1. Have a pre-existing qmd database with collections named memory, clawd, life
  2. Configure OpenClaw to use qmd backend with memory.qmd.command pointing to external qmd
  3. OpenClaw creates its own isolated qmd environment at ~/.openclaw/agents/<agentId>/qmd/xdg-cache/
  4. When the isolated qmd inherits or copies collection contexts from an external source, collection names may be memory instead of memory-dir
  5. Call memory_search - results are returned as empty despite qmd query returning valid results

Root Cause

In qmd-manager.ts, the resolveDocLocation() function looks up collection paths using:

const root = this.collectionRoots.get(collection);
if (!root) return null;  // <-- returns null, result dropped

The collectionRoots map is populated with OpenClaw's expected collection names:

  • memory-root (for MEMORY.md)
  • memory-alt (for memory.md)
  • memory-dir (for memory/**/*.md)
  • Custom paths from config

But the qmd database may have collections named differently (e.g., memory instead of memory-dir), causing the lookup to fail.

Workaround

Delete the agent's qmd cache to force recreation:

rm -rf ~/.openclaw/agents/main/qmd/xdg-cache/qmd/

Then trigger a memory search - OpenClaw will recreate the collections with correct names.

Suggested Fix

  1. In resolveDocLocation(), add fallback logic to handle collection name variations
  2. Or: in ensureCollections(), detect and rename existing collections to match expected names
  3. Or: better document that external qmd databases should not be mixed with OpenClaw's isolated environment

Additional Issue: Timeout

A related issue: qmd query with local LLM query expansion can take 10-20 seconds. The default memory.qmd.limits.timeoutMs of 6000ms is too short, causing frequent timeouts. When qmd times out, it may return "No results found.\n" instead of valid JSON, causing JSON parse errors.

Suggest increasing default timeout to 30000ms or making it more prominent in documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions