Skip to content

mdMirror fallback directory resolves to CWD instead of ~/.openclaw/memory/md-mirror #627

@ScientificProgrammer

Description

@ScientificProgrammer

Plugin Version

1.1.0-beta.10

OpenClaw Version

2026.4.9 (commit 0512059)

Bug Description

When mdMirror.enabled: true but mdMirror.dir is not set, the fallback directory resolves to {CWD}/memory-md instead of a stable absolute path like ~/.openclaw/memory/md-mirror.

In index.ts, createMdMirrorWriter() computes:

const fallbackDir = api.resolvePath(config.mdMirror.dir || "memory-md");

Since "memory-md" is a relative path, api.resolvePath() resolves it relative to the current working directory. During gateway startup, openclaw doctor runs, or CLI invocations, the CWD varies — so the mirror files end up in arbitrary locations and the following warning is logged on every plugin load:

[plugins] mdMirror: no agent workspaces found, writes will use fallback dir: /some/random/cwd/memory-md

The existing getDefaultDbPath() function already follows the correct pattern — resolving to ~/.openclaw/memory/lancedb-pro using homedir() + join(). The mdMirror default should follow the same convention.

This bug was identified with the assistance of Claude Code (AI). The accompanying fix PR was also AI-assisted.

Expected Behavior

When mdMirror.dir is not explicitly configured, the fallback should resolve to ~/.openclaw/memory/md-mirror (an absolute path inside the OpenClaw data directory), regardless of CWD.

Steps to Reproduce

  1. Set plugins.entries.memory-lancedb-pro.config.mdMirror.enabled: true in ~/.openclaw/openclaw.json
  2. Do not set mdMirror.dir
  3. Restart the gateway (systemctl --user restart openclaw-gateway.service)
  4. Observe the log warning showing the CWD-relative fallback path:
    [plugins] mdMirror: no agent workspaces found, writes will use fallback dir: /home/user/memory-md
    
  5. Run openclaw doctor from a different directory — the fallback path changes to match that CWD

Error Logs / Screenshots

2026-04-14T21:43:39.614-05:00 [plugins] mdMirror: no agent workspaces found, writes will use fallback dir: /home/eric/memory-md

Embedding Provider

OpenAI

OS / Platform

Linux Mint (Ubuntu 24.04 base), Node.js v24.6.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions