Memory Enhancement
BGE-M3记忆增强插件,为OpenClaw添加长期记忆功能
Install
openclaw plugins install clawhub:@cv-forever/memory-enhancementMemory Enhancement Plugin
BGE-M3 based long-term memory enhancement plugin for OpenClaw.
Automatically retrieves relevant historical memories and injects them into conversation context.
Privacy
Data Flow: This plugin sends user conversation content to a configured BGE-M3 API server for embedding and retrieves relevant historical memories, which are then injected into the agent's context.
Default Configuration (Local-Only):
By default, the plugin connects to 127.0.0.1:8080 — a local API server running on your own machine. Your data stays on your device and never leaves your network.
What you should know:
- Conversation content is sent to the BGE-M3 API server for embedding computation
- Generated embeddings and memory data are persisted on the server
- If you override
apiHostto a remote server, your conversation data will be sent to that server - Logging: by default (
logDetailedContent: false), the plugin only logs metadata (query length, status codes, memory count). SetlogDetailedContent: trueto enable detailed query content logging
Controls:
- Set
enabled: falseto completely disable memory retrieval - Set
logDetailedContent: false(default) to prevent conversation content from appearing in logs - Run the BGE-M3 API server locally (default) to keep all data on your machine
Features
- Automatic memory retrieval — On each session start, queries the BGE-M3 API server for memories relevant to the current context, injects them into
before_prompt_build - Long-term memory storage —
add_memoriestool to save important conversations, decisions, and discoveries - Memory search —
retrieve_memoriestool to query stored memories on demand - Configurable — threshold, topK, cache, debug logging, all tunable via OpenClaw plugin config
How it works
Session Start
│
▼
before_prompt_build hook
│
├── Extract recent conversation text
├── Query BGE-M3 API (POST /retrieve)
├── Inject top-K relevant memories into prompt
│
▼
Agent response with memory context
Installation
openclaw plugins install @cv/memory-enhancement
openclaw gateway restart
Configuration
| Field | Default | Description |
|---|---|---|
| enabled | true | Enable/disable the plugin |
| apiHost | 127.0.0.1 | BGE-M3 API server host |
| apiPort | 8080 | BGE-M3 API server port |
| threshold | 0.5 | Similarity threshold (0.0–1.0) |
| topK | 3 | Max memories to inject |
| timeout | 15000 | API call timeout (ms) |
| maxRetries | 2 | Max retries on failure |
| cacheEnabled | true | Enable query cache |
| cacheTTL | 300 | Cache TTL (seconds) |
| debug | false | Verbose debug logging |
| logDetailedContent | false | Log detailed query content (default: false, metadata only) |
Prerequisites
- BGE-M3 API server running on the configured host:port
- OpenClaw >= 2026.4.0
Server Setup
Memory Enhancement 插件需要一个 BGE-M3 API 服务端来提供记忆检索能力。
服务端代码和部署说明在仓库的 server/ 目录中:
cd server
pip install -r requirements.txt
python3 memory_api_server_mac.py --port 8080
详见 server/README.md。
如果需要训练自己的 LoRA 适配器,请参考原始项目仓库(包含完整训练脚本、数据预处理流程和评估工具)。
Version
1.1.0 — Privacy improvements: added Privacy section to README, logDetailedContent config, privacy warning on plugin load
Author
小爪 🐾
