Skip to content

qmd: ensureCollections() silently fails when path+pattern conflicts with another collection name #25496

@Ramsbaby

Description

@Ramsbaby

Bug Description

When multiple agents (sonnet, opus, haiku) share the same workspace, ensureCollections() fails to create agent-scoped collections (e.g., memory-root-opus) because another agent's collection (e.g., memory-root-sonnet) already occupies the same path + pattern slot in the qmd database.

Root Cause

In qmd-manager, ensureCollections() calls addCollection() which runs:

qmd collection add <path> --name memory-root-opus --mask MEMORY.md

qmd CLI rejects this with:

A collection already exists for this path and pattern:
  Name: memory-root-sonnet (qmd://memory-root-sonnet/)
  Pattern: MEMORY.md

The error handler isCollectionAlreadyExistsError() checks for "already exists" in the message and returns true, causing the code to continue — treating it as if memory-root-opus was successfully created. But it was not.

Impact

  • Agent-scoped memory collections are never created for agents that start after the first one
  • memory_search fails with "Collection not found" for those agents
  • openclaw status reports "vector ready" while semantic search is completely broken

Suggested Fix

isCollectionAlreadyExistsError() should distinguish between:

  1. Same name exists (truly OK to skip) — check if message contains the exact collection name being created
  2. Same path+pattern exists under a different name (NOT OK) — should remove the conflicting collection first, then retry

Environment

  • OpenClaw 2026.2.21-2, macOS, 3 agents (sonnet/opus/haiku)
  • qmd with per-agent XDG_CONFIG_HOME/XDG_CACHE_HOME isolation
  • Each agent gets its own SQLite DB at ~/.openclaw/agents/{agentId}/qmd/xdg-cache/qmd/index.sqlite

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions