Skip to content

[Bug] MEMORY.md injected twice on Windows NTFS (case-insensitive filesystem) #43931

@Raven-wy

Description

@Raven-wy

Summary

On Windows with WSL2 where the workspace is mounted from a Windows NTFS path (e.g. D:\openclaw), the filesystem is case-insensitive. OpenClaw hardcodes two bootstrap patterns for memory:

pattern: "MEMORY.md"
pattern: "memory.md"

And in memory path resolution:

const memoryPaths = [path.join(workspaceDir, "MEMORY.md"), path.join(workspaceDir, "memory.md")];

On NTFS, both paths resolve to the same physical file, so it gets injected into the system prompt twice — doubling the token cost for every session.

Environment

  • OS: Windows 11 + WSL2 (Linux 6.6.87.2-microsoft-standard-WSL2)
  • Workspace: Windows NTFS path bind-mounted into Docker container
  • OpenClaw version: 2026.3.8 (3caab92)

Steps to Reproduce

  1. Deploy OpenClaw on Windows with workspace on a Windows NTFS path
  2. Create a MEMORY.md file in the workspace
  3. Observe MEMORY.md content appears twice in the system prompt bootstrap section

Expected Behavior

MEMORY.md injected once per session.

Actual Behavior

MEMORY.md injected twice (NTFS treats MEMORY.md and memory.md as the same file).

Impact

  • ~13K extra tokens injected per session (doubles MEMORY.md bootstrap cost)
  • Higher cacheWrite costs on every cold start / compaction

Suggested Fix

Deduplicate bootstrap file paths by real path before injection:

const seen = new Set();
const deduped = files.filter(f => {
  try {
    const real = fs.realpathSync(f.path);
    if (seen.has(real)) return false;
    seen.add(real);
    return true;
  } catch { return true; }
});

Workaround

None via openclaw.json. Moving workspace to a Linux native filesystem (Docker named volume or WSL2 native path) resolves the issue.

Metadata

Metadata

Assignees

No one assigned

    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