
一、系统架构openclaw-advanced-memory 是一个独立的 Memory 管理服务它通过以下方式与 OpenClaw 主程序交互┌─────────────────────────────────────────────────────────────┐ │ OpenClaw 主程序 │ │ (Gateway Agents) │ └─────────────────────────┬───────────────────────────────────┘ │ │ HTTP/WebSocket 调用 │ ┌─────────────────────────▼───────────────────────────────────┐ │ openclaw-advanced-memory 服务 │ │ │ │ ┌─────────────────────────────────────────────────────┐ │ │ │ 核心功能 │ │ │ │ - 分支对话管理 (类似 Git) │ │ │ │ - 智能Token优化 (4层摘要) │ │ │ │ - 三级缓存 (L1内存 L2Redis L3SQLite) │ │ │ │ - 异步I/O (批量写入) │ │ │ │ - 后台任务调度 │ │ │ └─────────────────────────────────────────────────────┘ │ └─────────────────────────┬───────────────────────────────────┘ │ │ 文件系统同步 │ ┌─────────────────────────▼───────────────────────────────────┐ │ Obsidian 知识库 │ │ (C:\OpenClaw图书馆) │ └─────────────────────────────────────────────────────────────┘二、集成方式方式 1独立服务模式推荐适用场景需要完整的 Memory 功能包括分支管理、Obsidian 同步步骤启动 Memory 服务cd C:\Users\Administrator\.openclaw node start-advanced-memory-system.js验证服务运行服务启动后会显示系统状态默认端口和配置已在脚本中预设Obsidian 同步每 15 分钟自动执行在 Agent 中使用在agent.json中添加配置{ memory: { type: advanced, endpoint: http://localhost:3000, enabled: true } }方式 2模块集成模式当前实现适用场景直接在 Agent 代码中调用 Memory 功能步骤在 Agent 代码中引入 Memory 模块const { createDefaultMemorySystem } require(C:\Users\Administrator\.openclaw\memory-system\dist\index.js); const memorySystem await createDefaultMemorySystem(main); await memorySystem.addMemory({ type: user_preference, content: 用户偏好使用 GLM-4.7 模型, importance: 0.9, tags: [preference, model] });2.在 openclaw.json 中配置{ agents: { defaults: { memory: { type: summary, window: 200, prune_threshold: 0.6, auto_save: true } } } }三、具体配置示例配置 1为特定 Agent 启用 Advanced Memory修改workspace-main/agent.json{ memory: { type: advanced, enabled: true, config: { branchManagement: true, tokenOptimization: true, cacheLevels: [l1, l2, l3], obsidianSync: { enabled: true, vaultPath: C:\OpenClaw图书馆, interval: 900000 } } } }四、操作步骤步骤 1启动 Memory 服务cd C:\Users\Administrator\.openclaw node start-advanced-memory-system.js步骤 2验证服务状态ls C:\OpenClaw图书馆\OpenClaw-Memory五、监控与维护Obsidian 同步日志C:\OpenClaw图书馆\OpenClaw-Memory\_同步日志\六、故障排查问题 1服务启动失败node --version # 需要 18.0.0 ls C:\Users\Administrator\.openclaw\memory-system\dist问题 2Obsidian 同步失败ls C:\OpenClaw图书馆七、最佳实践独立运行 Memory 服务定期备份监控性能优化 Token 使用