Use CortexDB as a long-term memory provider for OpenClaw agents.

OpenClaw Integration

OpenClaw is a personal AI assistant framework and CLI that runs locally and gives an LLM "eyes and hands" — file access, shell, browser, and chat-app control. CortexDB plugs into OpenClaw as a memory provider so the agent remembers you across sessions, machines, and weeks.

The plugin mirrors the shape of the Mem0 OpenClaw integration: two automatic behaviors (auto-recall and auto-capture) plus a set of model-callable memory_* tools.

Plugin Details

npm package: @cortexdb/openclaw

openclaw plugins install @cortexdb/openclaw
openclaw gateway --force

Configuration

The plugin entry lives in openclaw.json under plugins.entries. There are two setup modes.

Cloud mode (CortexDB Cloud)

"openclaw-cortexdb": {
  "enabled": true,
  "config": {
    "apiKey": "${CORTEXDB_API_KEY}",
    "userId": "alice"
  }
}

Get an API key at cortexdb.ai.

Self-hosted mode

"openclaw-cortexdb": {
  "enabled": true,
  "config": {
    "mode": "self-hosted",
    "apiUrl": "http://localhost:3141",
    "userId": "alice"
  }
}

Core Features

Two automatic behaviors run on every turn:

  • Auto-recall — before every prompt build, the plugin queries CortexDB for memories matching the current message and injects them into the system prompt as a preamble.
  • Auto-capture — after every assistant reply, the user/assistant exchange is sent to CortexDB on a non-blocking path so the agent loop never waits on the memory write.

CortexDB's tenant L0/L1 profile preamble means the agent has a stable "who is this user" block injected on every turn, independent of whether anything matched the query.

Agent-Available Tools

Five tools become available within the agent:

| Tool | Purpose | |---|---| | memory_search | Natural-language memory queries | | memory_list | View all stored memories | | memory_store | Explicitly save a fact | | memory_get | Retrieve a memory by ID | | memory_forget | Delete by ID or query (requires audit reason) |

CLI Commands

openclaw cortexdb search "query text"
openclaw cortexdb search "query text" --scope long-term
openclaw cortexdb search "query text" --scope session
openclaw cortexdb stats

Configuration Reference

| Field | Default | Description | |---|---|---| | mode | cloud | cloud or self-hosted | | apiUrl | https://api.cortexdb.ai (cloud) | CortexDB server URL | | apiKey | — | CortexDB API key (required in cloud mode) | | userId | — | Per-user identifier (required) | | agentId | — | Optional agent identifier stored with memories | | preambleTokens | 512 | Token budget for the always-on profile preamble | | recallTokens | 1024 | Token budget for per-turn auto-recall results |

Why CortexDB instead of the builtin

OpenClaw's builtin SQLite engine is great for single-machine use. CortexDB is the option you reach for when you need any of:

  • Distributed storage across multiple agent machines
  • Hybrid retrieval (vector + keyword + graph + temporal, fused)
  • Bitemporal knowledge graph for "what did we think was true when"
  • Cross-encoder reranking for higher-precision recall
  • Right-to-be-forgotten, legal holds, audit trails built in
  • Multi-tenant isolation with hierarchical scopes