openclaw - ✅(Solved) Fix QMD boot: memory-alt-* collection add fails every restart due to memory-root-* conflict [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#58643Fetched 2026-04-08 01:59:50
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
cross-referenced ×3closed ×1commented ×1locked ×1

On every gateway restart, QMD logs warnings for all agents:

warn memory qmd collection add skipped for memory-alt-main: qmd collection add /home/ubuntu/.openclaw/workspace --name memory-alt-main --glob memory.md failed (code 1): A collection already exists for this path and pattern:
 Name: memory-root-main (qmd://memory-root-main/)
 Pattern: **/*.md

This happens for all agents (main, researcher, coder, math-teacher) on every restart.

Error Message

warn memory qmd collection add skipped for memory-alt-main: qmd collection add /home/ubuntu/.openclaw/workspace --name memory-alt-main --glob memory.md failed (code 1): A collection already exists for this path and pattern:

Root Cause

Inspecting the bundled source (dist/backend-config-*.js) reveals two hardcoded collection base names:

  • memory-root — created on first boot
  • memory-alt — attempted on subsequent boots when memory-root already exists

The boot sequence creates memory-root-<agentId> on first run. On every subsequent restart it tries to add memory-alt-<agentId> for the same path/pattern, which QMD correctly rejects as a duplicate. The code doesn't detect the existing collection and bail out gracefully.

PR fix notes

PR #58736: fix(memory): prefer --mask over --glob for qmd collection pattern flag

Description (problem / solution / changelog)

Fixes #58618 Related #58643

Summary

  • Problem: QMD 2.0.1 accepts the --glob flag during collection add, but silently ignores it and falls back to the default **/*.md pattern. This causes strictly scoped collections (e.g., MEMORY.md) to be created as full-workspace collections instead.
  • Why it matters: It breaks multi-agent memory initialization. When OpenClaw tries to add a second collection under the same directory with a different pattern, QMD throws a path+pattern conflict, resulting in memory-alt-* registration failures on every gateway restart. It also silently pulls unintended files into the LLM memory context.
  • What changed: Defaulted collectionPatternFlag to --mask so OpenClaw uses the working flag first.
  • What did NOT change: The fallback mechanism is preserved for older environments where --mask might not be supported.

Change Type

  • Bug fix
  • Feature
  • Security hardening

Root Cause

collectionPatternFlag initializes as null, causing OpenClaw's negotiation logic to try --glob first. Because the qmd CLI does not exit with an error code when it ignores --glob, OpenClaw falsely assumes the flag succeeded and never falls back to --mask. Consequently, every collection is effectively created with the catch-all **/*.md pattern.

Evidence & Repro

Observed on gateway startup with QMD enabled. The narrower memory.md collection collides with an already-created memory-root-* collection:

12:05:19+08:00 [memory] qmd collection add skipped for memory-alt-tg: 
qmd collection add ~/.openclaw/workspace --name memory-alt-tg --glob memory.md failed (code 1): 
A collection already exists for this path and pattern:
Name: memory-root-tg (qmd://memory-root-tg/)
Pattern: **/*.md

Use 'qmd update' to re-index it, or remove it first with 'qmd collection remove memory-root-tg'

Expected: memory-root-* and memory-alt-* coexist in the same workspace targeting different patterns (**/.md vs MEMORY.md). Actual: The first collection is forced to **/.md, blocking the second.

Testing & Verification

  • Updated Tests: extensions/memory-core/src/memory/qmd-manager.test.ts
  • Added regression coverage to verify addCollection() correctly prefers --mask over --glob while preserving the fallback behavior.

Verification Steps:

  • Clear existing QMD collections (qmd collection remove ...).
  • Restart the gateway with multiple agents targeting the same workspace.
  • Verify that collections are successfully created without conflict warnings and strictly adhere to their intended patterns.

Compatibility / Risks

  • Backward compatible? Yes. If --mask fails, it falls back to --glob.
  • Migration needed? Users encountering the bug may need to clear their existing conflicting collections (qmd collection remove memory-root-<agent>) so they can be rebuilt correctly.

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • extensions/memory-core/src/memory/qmd-manager.test.ts (modified, +13/-7)
  • extensions/memory-core/src/memory/qmd-manager.ts (modified, +1/-1)

Code Example

warn memory qmd collection add skipped for memory-alt-main: qmd collection add /home/ubuntu/.openclaw/workspace --name memory-alt-main --glob memory.md failed (code 1): A collection already exists for this path and pattern:
 Name: memory-root-main (qmd://memory-root-main/)
 Pattern: **/*.md
RAW_BUFFERClick to expand / collapse

Bug Report

Version: v2026.3.31 Platform: Linux arm64 (Ubuntu), npm global install

Summary

On every gateway restart, QMD logs warnings for all agents:

warn memory qmd collection add skipped for memory-alt-main: qmd collection add /home/ubuntu/.openclaw/workspace --name memory-alt-main --glob memory.md failed (code 1): A collection already exists for this path and pattern:
 Name: memory-root-main (qmd://memory-root-main/)
 Pattern: **/*.md

This happens for all agents (main, researcher, coder, math-teacher) on every restart.

Root Cause

Inspecting the bundled source (dist/backend-config-*.js) reveals two hardcoded collection base names:

  • memory-root — created on first boot
  • memory-alt — attempted on subsequent boots when memory-root already exists

The boot sequence creates memory-root-<agentId> on first run. On every subsequent restart it tries to add memory-alt-<agentId> for the same path/pattern, which QMD correctly rejects as a duplicate. The code doesn't detect the existing collection and bail out gracefully.

Steps to Reproduce

  1. Enable QMD backend (memory.backend: "qmd")
  2. Start gateway — memory-root-<agentId> collections are created
  3. Restart gateway
  4. Observe memory-alt-* conflict warnings in logs on every subsequent restart

Expected Behavior

OpenClaw should detect that a collection already exists for the given path+pattern and skip the add attempt without logging a warning, or rename/reuse the existing collection.

Impact

Cosmetic/noise only — the memory-root-* collections are correctly indexed and used. But the warnings appear on every restart and make it harder to spot real errors in logs.

extent analysis

TL;DR

Modify the backend configuration to detect and reuse existing collections instead of attempting to add duplicate collections.

Guidance

  • Review the dist/backend-config-*.js files to identify the hardcoded collection base names and modify them to handle existing collections.
  • Update the boot sequence to check for existing collections before attempting to add new ones, and skip or reuse them if they already exist.
  • Consider implementing a mechanism to dynamically generate unique collection names or reuse existing ones based on the agent ID and path/pattern.
  • Verify that the changes resolve the issue by restarting the gateway and checking the logs for the absence of duplicate collection warnings.

Example

// Pseudo-code example of checking for existing collections
if (collectionExists(path, pattern)) {
  // Reuse or skip existing collection
  console.log(`Collection already exists for ${path} and ${pattern}, skipping...`);
} else {
  // Add new collection
  addCollection(path, pattern);
}

Notes

The provided solution assumes that the issue is solely related to the hardcoded collection base names and the lack of detection for existing collections. Further investigation may be required to ensure that the proposed changes do not introduce any unintended consequences.

Recommendation

Apply a workaround by modifying the backend configuration to detect and reuse existing collections, as the root cause is related to the hardcoded collection names and the absence of a mechanism to handle existing collections.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix QMD boot: memory-alt-* collection add fails every restart due to memory-root-* conflict [1 pull requests, 1 comments, 2 participants]