Lily Memory:Openclaw Skills 的持久化长期记忆

作者:互联网

2026-04-15

AI教程

什么是 Lily Memory?

Lily Memory 是一款精密设计的扩展插件,旨在为您的智能体提供永久的认知印记。通过将其集成到 Openclaw Skills 中,您可以让智能体在会话重置、压缩和重启后依然保留关键信息。它采用零依赖架构,依靠 SQLite 等原生系统工具进行高性能关键字索引,并利用 Ollama 进行高级向量嵌入。

该技能确保每次交互都能增加累积知识库,从而实现无缝的上下文检索。无论是记录特定的项目配置,还是跟踪长期用户偏好,Lily Memory 都是持久化智能体工作流的中枢神经系统。

下载入口:https://github.com/openclaw/skills/tree/main/skills/kevinodell/lily-memory-plugin

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install lily-memory-plugin

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 lily-memory-plugin。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

Lily Memory 应用场景

  • 在多个开发会话中管理长期项目上下文。
  • 从智能体与用户的对话中自动提取并存储事实。
  • 通过内置的停滞检测机制打破智能体推理中的无限循环。
  • 创建一个可搜索的过往决策和系统配置知识库。
Lily Memory 工作原理
  1. 关键字提取:该技能分析传入的消息,以识别用于检索的主要关键字。
  2. 混合搜索:它利用 SQLite FTS5 进行精确匹配,并利用 Ollama 进行基于向量的语义相似度搜索,同时执行这两项操作。
  3. 上下文注入:在 LLM 处理当前轮次之前,相关记忆会被去重并注入到提示词上下文中。
  4. 自动捕获:插件监控智能体的响应模式,以识别并将新事实保存到数据库中。
  5. 逻辑监控:它计算连续响应的 Jaccard 相似度,以检测主题重复并引导智能体回到正轨。

Lily Memory 配置指南

要将此记忆层集成到您的 Openclaw Skills 中,请确保已安装 Node.js 18+ 和 SQLite 3.33+。请按照以下步骤操作:

  1. 将插件文件安装到您的扩展目录中。
  2. 更新您的 openclaw.json 配置:
{
  "plugins": {
    "slots": { "memory": "lily-memory" },
    "entries": {
      "lily-memory": {
        "enabled": true,
        "config": {
          "dbPath": "~/.openclaw/memory/decisions.db",
          "entities": ["config", "system"]
        }
      }
    }
  }
}
  1. 重启网关以应用更改:
openclaw gateway restart

Lily Memory 数据架构与分类体系

Lily Memory 在持久化 SQLite 数据库中组织数据。它管理事实、实体和向量嵌入,以优化 Openclaw Skills 的性能。

可用工具

工具 功能
memory_search 在存储的事实中执行 FTS5 关键字搜索
memory_entity 检索与特定实体关联的所有存储事实
memory_store 手动将新事实持久化到数据库中
memory_semantic_search 通过 Ollama 执行向量相似度搜索
memory_add_entity 在运行时注册新的实体类型

配置选项

默认值 用途
autoRecall true 启用每轮次的自动记忆注入
autoCapture true 启用从响应中自动提取事实
vectorSearch true 启用通过 Ollama 进行语义相似度搜索
name: lily-memory
description: Persistent memory plugin for OpenClaw agents. Hybrid SQLite FTS5 keyword + Ollama vector semantic search with auto-capture, auto-recall, stuck-detection, and memory consolidation. Zero npm dependencies.
metadata:
  openclaw:
    requires:
      bins: [node, sqlite3]
    primaryEnv: ""

Lily Memory

Persistent memory plugin for OpenClaw agents. Gives your agent long-term memory that survives session resets, compaction, and restarts.

What It Does

  • Auto-recall: Injects relevant memories as context before each LLM turn
  • Auto-capture: Extracts facts from conversations and stores them automatically
  • Hybrid search: SQLite FTS5 keyword search + Ollama vector cosine similarity
  • Stuck detection: Detects topic repetition and nudges the agent to break loops
  • Memory consolidation: Deduplicates entries on startup
  • Dynamic entities: Config-driven allowlist + runtime tool to add entities
  • Graceful degradation: Works without Ollama (keyword-only mode)
  • Zero npm dependencies: Uses sqlite3 CLI + native fetch

Requirements

  • Node.js 18+ (for native fetch)
  • SQLite 3.33+ with FTS5 (ships with macOS; apt install sqlite3 on Linux)
  • Optional: Ollama with nomic-embed-text model for semantic search

Quick Start

  1. Install the plugin to your extensions directory
  2. Add to your openclaw.json:
{
  "plugins": {
    "slots": { "memory": "lily-memory" },
    "entries": {
      "lily-memory": {
        "enabled": true,
        "config": {
          "dbPath": "~/.openclaw/memory/decisions.db",
          "entities": ["config", "system"]
        }
      }
    }
  }
}
  1. Restart the gateway: openclaw gateway restart

Tools

Tool Description
memory_search FTS5 keyword search across all facts
memory_entity Look up all facts for a specific entity
memory_store Save a fact to persistent memory
memory_semantic_search Vector similarity search via Ollama
memory_add_entity Register a new entity at runtime

Configuration

Option Type Default Description
dbPath string ~/.openclaw/memory/decisions.db SQLite database path
autoRecall boolean true Inject memories before each turn
autoCapture boolean true Extract facts from responses
maxRecallResults number 10 Max memories per turn
maxCapturePerTurn number 5 Max facts per response
stuckDetection boolean true Topic repetition detection
vectorSearch boolean true Ollama semantic search
ollamaUrl string http://localhost:11434 Ollama endpoint
embeddingModel string nomic-embed-text Embedding model
consolidation boolean true Dedup on startup
vectorSimilarityThreshold number 0.5 Min cosine similarity
entities array [] Additional entity names

Architecture

Recall flow: Extract keywords from message -> FTS5 + vector search -> merge and deduplicate -> inject as context

Capture flow: Regex scan for entity: key = value patterns -> validate entity against allowlist -> store to SQLite -> async embed via Ollama

Stuck detection: Track top 5 content words per response -> Jaccard similarity -> if 3+ consecutive >60% overlap, inject Reflexion nudge

License

MIT

相关推荐