Loading...
Loading...
Use OpenClaw MemX for long-term agent memory with self-learning, relationship graphs, and automatic maintenance
npx skill4agent add aradotso/hermes-skills openclaw-memx-memory-pluginSkill by ara.so — Hermes Skills collection.
# Clone the repository
git clone https://github.com/NeoLi00/openclaw-memx.git
cd openclaw-memx
# Install plugin
openclaw plugins install .
# Setup with local embeddings (recommended)
openclaw memx setup --local-embedding
# Restart gateway
openclaw gateway restart
# Verify installation
openclaw memx doctor --deep# Link plugin for development
openclaw plugins install --link .# Create Python virtual environment for embeddings
python3 -m venv "$HOME/.openclaw/memx/.venv"
"$HOME/.openclaw/memx/.venv/bin/python" -m pip install -U pip sentence-transformers torch
# Setup MemX with local embeddings
openclaw memx setup \
--local-embedding \
--embedding-python "$HOME/.openclaw/memx/.venv/bin/python"# Configure LLM provider (use environment variable for API key)
export DEEPSEEK_API_KEY="your-api-key-here"
openclaw config set models.providers.deepseek '{
"api": "openai-completions",
"baseUrl": "https://api.deepseek.com",
"apiKey": "${DEEPSEEK_API_KEY}",
"models": [
{
"id": "deepseek-v4-flash",
"name": "DeepSeek V4 Flash",
"api": "openai-completions",
"reasoning": false,
"input": ["text"],
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
"contextWindow": 64000,
"maxTokens": 8192
}
]
}' --strict-json
# Setup MemX with LLM model and local embeddings
openclaw memx setup \
--local-embedding \
--embedding-python "$HOME/.openclaw/memx/.venv/bin/python" \
--llm-model deepseek/deepseek-v4-flash
openclaw gateway restartexport EMBEDDING_API_KEY="your-embedding-key"
openclaw memx setup \
--embedding-provider openai-compatible \
--embedding-model text-embedding-3-small
openclaw config set plugins.entries.memory-memx.config.embedding.baseURL https://api.openai.com/v1
openclaw config set plugins.entries.memory-memx.config.embedding.apiKey '${EMBEDDING_API_KEY}'openclaw memx setup \
--embedding-provider ollama \
--embedding-model nomic-embed-text
openclaw config set plugins.entries.memory-memx.config.embedding.ollamaBaseURL http://127.0.0.1:11434python3 -m pip install --user sentence-transformers torch
openclaw memx setup \
--embedding-provider sentence-transformers-local \
--embedding-model BAAI/bge-m3 \
--embedding-device autoopenclaw memx setup --embedding-provider offopenclaw gateway restart
openclaw memx reindex# Initial setup with local embeddings
openclaw memx setup --local-embedding
# Setup with specific embedding Python runtime
openclaw memx setup --local-embedding --embedding-python /path/to/.venv/bin/python
# Setup with specific LLM model
openclaw memx setup --llm-model provider/model
# Verify installation and configuration
openclaw memx doctor
# Deep verification with embedding and LLM tests
openclaw memx doctor --deep
# Reindex all memories (after embedding provider change)
openclaw memx reindex
# Restart gateway after configuration changes
openclaw gateway restartmemory_searchmemory_getopenclaw config set plugins.entries.memory-memx.config.advanced.enableCompatibilityMemoryTools true
openclaw gateway restartmemx setupopenclaw memx setupmemory-memxplugins.allowplugins.slots.memorymemory-memxplugins.entries.memory-memx.hooks.allowPromptInjectionadvanced.enableCompatibilityMemoryTools=falsememx setupMEMORY.mdMEMORY.mdmemory/*.mdimport { execSync } from 'child_process';
function checkMemXInstallation(): boolean {
try {
const result = execSync('openclaw memx doctor', { encoding: 'utf-8' });
return result.includes('MemX is ready');
} catch (error) {
console.error('MemX not properly installed:', error);
return false;
}
}import { execSync } from 'child_process';
function verifyMemXConfig(): void {
try {
// Check if memory slot is assigned to MemX
const config = execSync('openclaw config get plugins.slots.memory', { encoding: 'utf-8' });
if (config.trim() === 'memory-memx') {
console.log('✓ MemX is active memory provider');
} else {
console.warn('⚠ MemX is not the active memory provider');
}
} catch (error) {
console.error('Failed to check MemX configuration:', error);
}
}import { execSync } from 'child_process';
import * as fs from 'fs';
import * as path from 'path';
interface MemXSetupOptions {
embeddingProvider?: 'local' | 'openai' | 'ollama' | 'off';
llmModel?: string;
embeddingPython?: string;
}
function setupMemX(options: MemXSetupOptions = {}): void {
const {
embeddingProvider = 'local',
llmModel,
embeddingPython
} = options;
try {
// Install Python dependencies for local embeddings
if (embeddingProvider === 'local') {
console.log('Installing Python dependencies...');
const pythonBin = embeddingPython || 'python3';
execSync(`${pythonBin} -m pip install --user sentence-transformers torch`, {
stdio: 'inherit'
});
}
// Build setup command
let setupCmd = 'openclaw memx setup';
if (embeddingProvider === 'local') {
setupCmd += ' --local-embedding';
if (embeddingPython) {
setupCmd += ` --embedding-python ${embeddingPython}`;
}
} else if (embeddingProvider === 'off') {
setupCmd += ' --embedding-provider off';
}
if (llmModel) {
setupCmd += ` --llm-model ${llmModel}`;
}
console.log(`Running: ${setupCmd}`);
execSync(setupCmd, { stdio: 'inherit' });
// Restart gateway
console.log('Restarting OpenClaw gateway...');
execSync('openclaw gateway restart', { stdio: 'inherit' });
// Verify installation
console.log('Verifying installation...');
execSync('openclaw memx doctor --deep', { stdio: 'inherit' });
console.log('✓ MemX setup complete');
} catch (error) {
console.error('MemX setup failed:', error);
throw error;
}
}
// Usage
setupMemX({
embeddingProvider: 'local',
llmModel: 'deepseek/deepseek-v4-flash',
embeddingPython: `${process.env.HOME}/.openclaw/memx/.venv/bin/python`
});# 1. Install OpenClaw (if not already installed)
# 2. Configure an LLM provider
export LLM_API_KEY="your-api-key"
openclaw config set models.providers.yourprovider '{
"api": "openai-completions",
"baseUrl": "https://api.provider.com",
"apiKey": "${LLM_API_KEY}",
"models": [
{
"id": "model-id",
"name": "Model Name",
"api": "openai-completions",
"reasoning": false,
"input": ["text"],
"cost": { "input": 0, "output": 0 },
"contextWindow": 32000,
"maxTokens": 4096
}
]
}' --strict-json
# 3. Install and setup MemX
git clone https://github.com/NeoLi00/openclaw-memx.git
cd openclaw-memx
openclaw plugins install .
python3 -m venv "$HOME/.openclaw/memx/.venv"
"$HOME/.openclaw/memx/.venv/bin/python" -m pip install -U pip sentence-transformers torch
openclaw memx setup \
--local-embedding \
--embedding-python "$HOME/.openclaw/memx/.venv/bin/python" \
--llm-model yourprovider/model-id
openclaw gateway restart
openclaw memx doctor --deep# Switch from local to OpenAI embeddings
export EMBEDDING_API_KEY="your-key"
openclaw memx setup \
--embedding-provider openai-compatible \
--embedding-model text-embedding-3-small
openclaw config set plugins.entries.memory-memx.config.embedding.apiKey '${EMBEDDING_API_KEY}'
openclaw gateway restart
openclaw memx reindex# 1. MemX does not auto-migrate MEMORY.md
# 2. Manually review and convert important content:
# - Have a conversation with the agent about the content
# - Important facts will be automatically stored by MemX
# 3. Archive old memory files
mkdir -p legacy-memory
mv MEMORY.md memory/*.md legacy-memory/ 2>/dev/null || true# Run deep diagnostics
openclaw memx doctor --deep
# Common issues and fixes:
# Issue: Memory slot not assigned to MemX
openclaw memx setup --local-embedding
openclaw gateway restart
# Issue: Embedding model not available
python3 -m pip install --user sentence-transformers torch
# Issue: LLM model not configured
openclaw config set plugins.entries.memory-memx.config.advanced.llmClassifierModel provider/model
openclaw gateway restart
# Issue: Plugin not in allow list
openclaw config set plugins.allow '["memory-memx"]' --json
openclaw gateway restart# Check Python dependencies
python3 -c "import sentence_transformers; print(sentence_transformers.__version__)"
# Reinstall dependencies
python3 -m pip install --user --force-reinstall sentence-transformers torch
# Use specific Python runtime
openclaw memx setup --local-embedding --embedding-python /path/to/python
# Switch to different provider if local embeddings fail
openclaw memx setup --embedding-provider ollama --embedding-model nomic-embed-text
openclaw gateway restart# Verify memory slot ownership
openclaw config get plugins.slots.memory
# Should return: memory-memx
# Verify prompt injection is enabled
openclaw config get plugins.entries.memory-memx.hooks.allowPromptInjection
# Should return: true
# Check if memories exist
openclaw memx doctor --deep
# Look for "stored memories" count
# Force reindex
openclaw memx reindex# Stop and restart cleanly
openclaw gateway stop
sleep 2
openclaw gateway start
# Check gateway logs
openclaw gateway logs
# Verify plugin loaded
openclaw plugins list
# Should show memory-memx as active# MemX automatically maintains memory
# To manually trigger maintenance (advanced):
# Contact: neoliriven@gmail.com for maintenance configuration
# Check memory database size
ls -lh ~/.openclaw/memory-memx/
# Typical size varies with usageintfloat/multilingual-e5-smallmemx doctor --deepmemx setupMEMORY.md~/.openclaw/memory-memx/ARCHITECTURE.md