Skip to content

FalkorDB/openclaw-mem0-demo

Repository files navigation

OpenClaw + Mem0 + FalkorDB — Persistent Graph Memory for AI Agents

Give your OpenClaw assistant persistent, graph-structured memory using Mem0 and FalkorDB. The agent remembers user preferences, facts, and relationships across sessions — automatically.

Architecture

┌─────────────┐     ┌──────────────────┐     ┌─────────────┐
│  OpenClaw   │────▶│@falkordb/openclaw│────▶│  FalkorDB   │
│  (Agent)    │     │  -mem0 (Plugin)  │     │  (Graphs)   │
└─────────────┘     └────────┬─────────┘     └─────────────┘
                             │
                      ┌──────▼──────┐
                      │   OpenAI    │
                      │ (Embeddings │
                      │  + LLM)     │
                      └─────────────┘

How the pieces fit together:

Component Role
OpenClaw Personal AI assistant — the agent runtime and chat interface
@falkordb/openclaw-mem0 OpenClaw plugin — auto-recall/capture + 5 memory tools, with FalkorDB graph support
Mem0 Node.js SDK Memory management — extracts, stores, and retrieves facts
@falkordb/mem0 TypeScript library — FalkorDB as a graph store for Mem0 (bundled in the plugin)
FalkorDB Graph database — stores entity relationships per user
OpenAI Embeddings for semantic search + LLM for entity extraction

Memory flow:

  1. You chat with your OpenClaw agent on any channel (WhatsApp, Telegram, Slack, CLI, etc.)
  2. Auto-Capture: After each response, the mem0 plugin extracts entities and relationships
  3. Auto-Recall: Before each response, vector search + graph traversal inject relevant memories
  4. FalkorDB stores entity relationships as isolated per-user graphs (mem0_alice, mem0_bob)

Prerequisites

  • Node.js ≥ 22 (for OpenClaw)
  • Docker (for FalkorDB)
  • Redis CLI (redis-cli — for verifying and inspecting FalkorDB)
  • uv (for Python verification scripts)
  • OpenAI API key

Quick Start

1. Start FalkorDB

docker compose up -d

Verify it's running:

redis-cli -h localhost -p 6379 ping
# → PONG

2. Set up environment

cp .env.example .env
# Edit .env and add your OPENAI_API_KEY

3. Install and configure OpenClaw

# Install OpenClaw globally
npm install -g openclaw@latest

# Install the FalkorDB-enabled Mem0 memory plugin
openclaw plugins install @falkordb/openclaw-mem0

# Copy the provided config (OSS mode — fully self-hosted, no Mem0 Cloud needed)
mkdir -p ~/.openclaw && cp openclaw.json ~/.openclaw/openclaw.json

4. Start the OpenClaw gateway

openclaw onboard --install-daemon
# Or run directly:
openclaw gateway --port 18789 --verbose

5. Chat with your memory-enabled agent

# Send a message — the agent will auto-capture facts
openclaw agent --local --session-id demo --message "I'm a software engineer who loves Rust and hiking"

# Later, the agent auto-recalls relevant memories
openclaw agent --local --session-id demo --message "Recommend me a weekend project"
# → Agent remembers you like Rust and hiking!

# Use the CLI to search memories directly
openclaw mem0 search "what languages does the user know"

# View memory stats
openclaw mem0 stats

Add Mem0 Memory to an Existing OpenClaw Setup

Already have OpenClaw running? Follow these steps to add persistent graph memory powered by Mem0 and FalkorDB.

1. Start FalkorDB

Choose one of the following:

Option A — Local (Docker)

docker run -d --name falkordb -p 6379:6379 -p 3000:3000 falkordb/falkordb:latest

Verify it's running:

redis-cli -h localhost -p 6379 ping
# → PONG

Option B — FalkorDB Cloud

  1. Sign up at app.falkordb.cloud
  2. Create an instance and note the host, port, username, and password

2. Install the Mem0 plugin

openclaw plugins install @falkordb/openclaw-mem0

Verify it's installed:

openclaw plugins list
# → Should show @falkordb/openclaw-mem0

3. Update your OpenClaw config

Open your existing config file (~/.openclaw/openclaw.json) and add the mem0 plugin configuration.

Add the following to your config — merge it with any existing settings you already have:

{
  // ... your existing config ...

  "plugins": {
    "slots": {
      "memory": "openclaw-mem0"    // ← replace default memory-core with mem0
    },
    "entries": {
      "openclaw-mem0": {
        "enabled": true,
        "config": {
          "mode": "open-source",
          "userId": "alice",         // ← change to your user identifier
          "autoRecall": true,
          "autoCapture": true,
          "enableGraph": true,
          "topK": 5,
          "searchThreshold": 0.3,
          "oss": {
            "embedder": {
              "provider": "openai",
              "config": { "model": "text-embedding-3-small" }
            },
            "vectorStore": {
              "provider": "memory",
              "config": { "dimension": 1536 }
            },
            "graphStore": {
              "provider": "falkordb",
              "config": {
                // Local Docker:
                "host": "localhost",
                "port": 6379,
                "graphName": "mem0"

                // FalkorDB Cloud — replace the above with:
                // "host": "your-instance.falkordb.cloud",
                // "port": 6379,
                // "username": "default",
                // "password": "your-password",
                // "graphName": "mem0"
              }
            },
            "llm": {
              "provider": "openai",
              "config": { "model": "gpt-4o-mini" }
            }
          }
        }
      }
    }
  }
}

4. Set your OpenAI API key

The mem0 plugin needs an OpenAI key for embeddings and entity extraction. Set it as an environment variable:

export OPENAI_API_KEY="sk-your-key-here"

To make it permanent, add it to your shell profile (~/.bashrc, ~/.zshrc, etc.) or use a .env file in your OpenClaw workspace.

5. Restart the OpenClaw gateway

# Stop the running gateway, then restart it
openclaw gateway --port 18789 --verbose

Or if you installed it as a daemon:

openclaw onboard --install-daemon

6. Chat and verify memory is working

Send a few messages so the agent captures some facts:

openclaw agent --local --session-id demo --message "I'm a software engineer who loves Rust and hiking"
openclaw agent --local --session-id demo --message "Recommend me a weekend project"
# → Agent should recall your preferences!

7. Verify in FalkorDB Browser

FalkorDB includes a built-in browser UI for visualizing your graphs.

  1. Open http://localhost:3000 in your browser (for local Docker), or use the browser at app.falkordb.cloud for cloud instances
  2. Select the graph named mem0_alice (or mem0_<your-userId>)
  3. Run a query to see stored entities and relationships:
MATCH (a)-[r]->(b) RETURN a, r, b

You should see nodes representing extracted entities (people, technologies, hobbies, etc.) and edges showing their relationships — confirming that Mem0 is capturing and storing memories in FalkorDB.

Tip: You can also verify via the CLI:

redis-cli -h localhost -p 6379
GRAPH.LIST
GRAPH.QUERY mem0_alice "MATCH (n) RETURN n.name LIMIT 10"

OpenClaw Configuration

This repo includes two ready-to-use configs:

openclaw.json — OSS Mode (default, self-hosted)

Fully local — no Mem0 Cloud account needed. Uses OpenAI for embeddings/LLM and FalkorDB for graph storage via @falkordb/openclaw-mem0.

Key config points:

  • gateway.mode: "local" — required for local-only operation
  • plugins.slots.memory: "openclaw-mem0" — tells OpenClaw to use the mem0 plugin instead of the default memory-core
  • oss.graphStore — configures FalkorDB as the graph backend
{
  "gateway": { "mode": "local" },
  "plugins": {
    "slots": { "memory": "openclaw-mem0" },
    "entries": {
      "openclaw-mem0": {
        "enabled": true,
        "config": {
          "mode": "open-source",
          "userId": "alice",
          "autoRecall": true,
          "autoCapture": true,
          "enableGraph": true,
          "topK": 5,
          "searchThreshold": 0.3,
          "oss": {
            "embedder": { "provider": "openai", "config": { "model": "text-embedding-3-small" } },
            "vectorStore": { "provider": "memory", "config": { "dimension": 1536 } },
            "graphStore": {
              "provider": "falkordb",
              "config": { "host": "localhost", "port": 6379, "graphName": "mem0" }
            },
            "llm": { "provider": "openai", "config": { "model": "gpt-4o-mini" } }
          }
        }
      }
    }
  }
}

openclaw.platform-mode.json — Platform Mode (Mem0 Cloud)

Uses Mem0's managed cloud with enableGraph: true for built-in graph entity relationships.

{
  "plugins": {
    "entries": {
      "openclaw-mem0": {
        "enabled": true,
        "config": {
          "mode": "platform",
          "apiKey": "${MEM0_API_KEY}",
          "userId": "alice",
          "enableGraph": true       // entity graph for relationships
        }
      }
    }
  }
}

To use Platform Mode: set MEM0_API_KEY in .env and copy openclaw.platform-mode.json to ~/.openclaw/openclaw.json:

mkdir -p ~/.openclaw && cp openclaw.platform-mode.json ~/.openclaw/openclaw.json

Agent Memory Tools

The mem0 plugin gives your OpenClaw agent five tools it can use during conversations:

Tool Description
memory_search Search memories by natural language
memory_store Explicitly save a fact (long-term or session)
memory_list List all stored memories for a user
memory_get Retrieve a specific memory by ID
memory_forget Delete a memory by ID or query

Memory Scopes

Scope Behavior
Session (short-term) Auto-captured during the current conversation
User (long-term) Persists across all sessions for the user

Auto-recall searches both scopes and presents long-term memories first.

Verifying the Backend (Python Scripts)

The Python scripts let you test the Mem0 + FalkorDB backend directly — useful for verifying the graph store is working before connecting OpenClaw.

# Install Python dependencies
uv sync

# Quick test — add memories and search
uv run python demo_basic.py

# Full demo — multi-user isolation, updates, cleanup
uv run python demo.py

demo_basic.py — Minimal Quick Start

Registers mem0-falkordb, adds memories, and searches — ~30 lines.

demo.py — Comprehensive Backend Demo

Scenario What it demonstrates
Add & Search Store facts, search with natural language queries
Multi-User Isolation Each user gets their own FalkorDB graph — no data leaks
Memory Updates Mem0 handles conflicting info automatically
List Memories Inspect all stored memories for a user
Cleanup Drop a user's entire graph with one call

Inspecting the Graph

Connect to FalkorDB and query the graph directly:

redis-cli -h localhost -p 6379

# List all graphs
GRAPH.LIST

# Query alice's memory graph
GRAPH.QUERY mem0_alice "MATCH (n) RETURN n LIMIT 10"

# See entity relationships
GRAPH.QUERY mem0_alice "MATCH (a)-[r]->(b) RETURN a.name, type(r), b.name"

Configuration Reference

OpenClaw Plugin Options

Key Type Default Description
mode "platform" | "open-source" "platform" Backend mode
userId string "default" Scope memories per user
autoRecall boolean true Inject memories before each turn
autoCapture boolean true Store facts after each turn
topK number 5 Max memories per recall
searchThreshold number 0.3 Min similarity (0–1)
enableGraph boolean false Enable entity graph (supported in both OSS and platform modes)
oss.graphStore.provider string Graph store provider (e.g., "falkordb")
oss.graphStore.config object host, port, graphName, username, password

FalkorDB Connection (Python scripts)

config = {
    "graph_store": {
        "provider": "falkordb",
        "config": {
            "host": "localhost",       # FalkorDB host
            "port": 6379,              # FalkorDB port
            "database": "mem0",        # Graph name prefix
        },
    },
    "llm": {
        "provider": "openai",
        "config": {"model": "gpt-4o-mini"},
    },
}

Each user gets their own isolated graph: {database}_{user_id} (e.g., mem0_alice).

Using FalkorDB Cloud

Replace localhost:6379 with your cloud instance:

"config": {
    "host": "your-instance.falkordb.cloud",
    "port": 6379,
    "username": "default",
    "password": "your-password",
    "database": "mem0",
}

Sign up at app.falkordb.cloud.

Troubleshooting

Problem Solution
ConnectionError to FalkorDB Ensure docker compose up -d is running and port 6379 is free
OPENAI_API_KEY error Copy .env.example to .env and add your key
OpenClaw plugin not loading Run openclaw plugins list to verify, then openclaw doctor
Empty search results Verify memories were added with openclaw mem0 stats or m.get_all()
Python import errors Run with uv run or activate the venv: source .venv/bin/activate
register() not called (Python) Must call register() before Memory.from_config()

Resources

License

MIT

About

OpenClaw + Mem0 + FalkorDB — Persistent Graph Memory for AI Agents

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages