简介
Lily Memory Plugin
原始描述
Persistent memory plugin for OpenClaw agents. Hybrid SQLite FTS5 keyword + Ollama vector semantic search with auto-capture, auto-recall, stuck-detection, and...
通过你的 Agent 添加
安装目录:lily-memory/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
Lily Memory 是专为 OpenClaw 智能体设计的持久化记忆插件,通过 SQLite FTS5 关键字搜索与 Ollama 向量语义搜索的混合架构,为 Agent 提供长期记忆能力。安装后,插件会自动在每次 LLM 交互前注入相关记忆上下文,并从对话中自动提取结构化事实进行存储。
用户可通过五项核心工具主动管理记忆:memory_search 进行 FTS5 全文检索,memory_semantic_search 实现向量相似度查询,memory_entity 按实体维度回溯关联信息,memory_store 手动存入关键事实,memory_add_entity 动态扩展实体白名单。配置层面支持精细调控召回数量、捕获频率、向量阈值等参数,并可选启用话题重复检测与记忆去重功能。
显著优点
双模搜索架构:关键字检索确保精确匹配,向量语义捕捉概念关联,二者融合显著提升召回质量。
零感自动化:自动召回与捕获机制无需人工干预,Agent 自发形成记忆闭环,大幅降低使用成本。
优雅降级设计:无 Ollama 时自动切换为纯关键字模式,核心功能不受影响,部署灵活性极高。
防循环机制:内置 stuck-detection 通过 Jaccard 相似度监控话题重复,主动注入反思提示打破死循环。
数据主权保障:全本地存储,无云端依赖,符合 GDPR/CCPA 合规要求,敏感场景友好。
潜在局限
Ollama 性能瓶颈:向量嵌入生成依赖本地 Ollama 服务,大规模记忆场景下可能成为延迟瓶颈,需权衡 maxCapturePerTurn 与 maxRecallResults 配置。
实体白名单约束:自动捕获依赖预设实体类型,未注册的实体信息将被过滤,初期需一定配置投入。
SQLite 扩展上限:极端数据量下(百万级记忆条目)单文件 SQLite 可能面临性能衰减,需定期归档或分库。
语义理解边界:向量搜索质量受限于 nomic-embed-text 模型能力,专业领域术语的语义关联可能存在偏差。
适合群体
- 构建长期陪伴型 Agent 的产品团队,需要跨会话维持用户画像与上下文
- 开发复杂任务 Agent 的工程师,需避免多轮对话中的重复询问与循环困局
- 注重数据隐私的企业用户,要求记忆数据完全本地化处理
- 研究 Agent 记忆机制的研究者,可基于其模块化架构进行二次实验
使用风险
依赖维护:better-sqlite3 虽稳定仍需关注版本更新,旧版本可能存在未披露的 Node-API 兼容性问题。
存储管理:记忆数据库随时间膨胀,建议定期执行 consolidation 或手动清理,避免磁盘占用失控。
Ollama 可用性:向量功能依赖本地服务健康状态,服务异常时自动降级但语义搜索能力丧失,需监控端口连通性。
配置误用:过高的 maxRecallResults 可能导致上下文窗口溢出,与 LLM 的 token 限制产生冲突;过低的 vectorSimilarityThreshold 则引入噪音记忆。
备份义务:SQLite 单文件特性使其易受磁盘故障或误操作损坏,生产环境务必建立自动备份机制。
技能正文
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.
metadata:
openclaw:
requires:
bins: [node]
npm: [better-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)
- Minimal dependencies: Uses better-sqlite3 for secure parameterized queries + native fetch
Requirements
- Node.js 18+ (for native
fetch)
better-sqlite3 npm package (installed automatically)
- Optional: Ollama with
nomic-embed-text model for semantic search
Quick Start
- Install the plugin to your extensions directory
- Add to your
openclaw.json:
{
"plugins": {
"slots": { "memory": "lily-memory" },
"entries": {
"lily-memory": {
"enabled": true,
"config": {
"dbPath": "~/.openclaw/memory/decisions.db",
"entities": ["config", "system"]
}
}
}
}
}
- 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
- Node.js 18+ (for native
fetch) better-sqlite3npm package (installed automatically)- Optional: Ollama with
nomic-embed-textmodel for semantic search
Quick Start
- Install the plugin to your extensions directory
- Add to your
openclaw.json:
{
"plugins": {
"slots": { "memory": "lily-memory" },
"entries": {
"lily-memory": {
"enabled": true,
"config": {
"dbPath": "~/.openclaw/memory/decisions.db",
"entities": ["config", "system"]
}
}
}
}
}
- 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
openclaw.json:{
"plugins": {
"slots": { "memory": "lily-memory" },
"entries": {
"lily-memory": {
"enabled": true,
"config": {
"dbPath": "~/.openclaw/memory/decisions.db",
"entities": ["config", "system"]
}
}
}
}
}
openclaw gateway restart| 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
| 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 |
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
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。