Skip to content

Mem0 is creating SQLite files in every CWD when using openclaw-mem0 plugin #5004

@kuoruan

Description

@kuoruan

Component

Core / Python SDK

Description

Package: openclaw-mem0 + mem0ai (TypeScript SDK)
Affected versions: mem0ai npm 3.0.0, 3.0.1, 3.0.2
Files:

  • mem0-ts/src/oss/src/config/defaults.ts (default value)
  • mem0-ts/src/oss/src/storage/SQLiteManager.ts (file creation)
  • openclaw-mem0 plugin dist/index.js (config propagation)

Description

When using openclaw-mem0 (the OpenClaw plugin wrapping mem0ai), running CLI commands like openclaw mem0 list from any directory creates a memory.db SQLite file in the current working directory.

This happens because mem0ai's default historyStore.config.historyDbPath is set to "memory.db" — a relative path:

// mem0-ts/src/oss/src/config/defaults.ts
historyStore: {
    provider: "sqlite",
    config: {
        historyDbPath: "memory.db",   // ← relative to CWD!
    },
},

Reproduction

cd /tmp
openclaw mem0 list
ls -la /tmp/memory.db   # ← 20KB SQLite file created

cd /var/tmp
openclaw mem0 list
ls -la /var/tmp/memory.db  # ← another one!

Root Cause

The config cascade in mem0-ts/src/oss/src/memory/index.ts (around line 4859):

historyDbPath: userConfig.historyDbPath ||
    userConfig.historyStore?.config?.historyDbPath ||
    DEFAULT_MEMORY_CONFIG.historyStore.config.historyDbPath  // ← "memory.db"

When the openclaw-mem0 plugin initializes via CLI (separate process), the explicitly configured oss.historyDbPath (an absolute path like /home/xxx/.openclaw/workspace/history.db) does not always propagate correctly through the config builder in all code paths. When it falls through, the relative default "memory.db" is used.

The SQLiteManager constructor then calls:

this.db = new Database(path.resolve("memory.db"));

Which resolves to <current-working-directory>/memory.db.

Impact

  • Minor annoyance: memory.db files accumulate in directories where CLI commands are run
  • Confusion: Users who configured PGVector as their vector store don't expect SQLite database files at all
  • Security: Users may not want SQLite files created in arbitrary directories

Workaround

For users who use PGVector (or any non-SQLite vector store) and don't need the SQLite history feature:

"oss": {
    "embedder": {...},
    "vectorStore": {...},
    "llm": {...},
    "disableHistory": true
}

This completely avoids creating any memory.db files since mem0 uses DummyHistoryManager instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions