Skip to content

QMD session recall roundtrip breaks because memory_search returns source alias instead of real collection name #43519

@holgergruenhagen

Description

@holgergruenhagen

Summary

When OpenClaw uses the QMD memory backend with session indexing enabled, memory_search returns session hit paths in the generic form:

  • qmd/sessions/<file>.md

But memory_get cannot read that path, because the QMD read path resolver expects the real collection name, e.g.:

  • sessions-coder

That breaks the memory_search -> memory_get roundtrip for session-backed QMD results.

Impact

Session hits returned by memory_search are not directly readable via memory_get, even though the underlying QMD collection and document exist and can be queried successfully.

This makes QMD-backed session recall partially unusable in normal agent workflows.

Reproduction

Preconditions

  • memory.backend=qmd
  • session memory / session indexing enabled
  • agent-specific QMD session collection exists, e.g. sessions-coder

Steps

  1. Index session content into QMD
  2. Run memory_search for text known to exist in a session export
  3. Take a returned path from the result
  4. Call memory_get with that exact path

Example

memory_search returns a result like:

  • qmd/sessions/e497305e-0e44-473e-b8d6-81d0c239ee4a.md

Then memory_get on that exact path fails with:

  • unknown qmd collection: sessions

Expected behavior

Paths returned by memory_search should be directly consumable by memory_get.

For session-backed QMD hits, that means the returned path should include the real QMD collection name, for example:

  • qmd/sessions-coder/e497305e-0e44-473e-b8d6-81d0c239ee4a.md

Actual behavior

memory_search serializes session results using the generic source alias:

  • qmd/sessions/...

But memory_get / QMD read-path resolution only accepts real collection keys from collectionRoots, such as:

  • sessions-coder

So the roundtrip fails.

Root cause

This appears to be a path serialization mismatch between QMD search result formatting and QMD read-path resolution:

  • search result path uses source alias (sessions)
  • read path resolver expects real collection name (sessions-<agentId>)

In short:

memory_search returns a generic alias path, while memory_get requires the concrete QMD collection name.

What was verified

  • raw QMD collection listing shows a real session collection such as sessions-coder
  • raw QMD search returns file references using the real collection, e.g. qmd://sessions-coder/...
  • OpenClaw search result normalization turns that into qmd/sessions/...
  • QMD read-path resolution rejects sessions because it is not an actual registered collection key

Suggested fix

Preferred fix

Change memory_search result serialization for QMD session hits so it returns the real collection name:

  • qmd/sessions-coder/<file>.md

instead of:

  • qmd/sessions/<file>.md

This keeps the roundtrip explicit and lossless.

Alternative (less preferred)

Teach memory_get to accept qmd/sessions/... as an alias and map it to the active session collection.

This would work, but it adds implicit aliasing and is less clean than returning a roundtrip-safe path from memory_search in the first place.

Acceptance criteria

  • memory_search returns roundtrip-safe QMD paths for session hits
  • memory_get(<path returned by memory_search>) works without manual rewriting
  • no regression for normal memory collections
  • works for agent-specific session collection names

Notes

The underlying QMD indexing and raw search are working correctly. The bug is specifically in the OpenClaw path mapping layer between search output and read input.

Metadata

Metadata

Assignees

Labels

No labels
No labels

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