🧠 Local Memory Plugin v0.4
A brain-like memory system for OpenClaw. Remembers what matters, forgets what doesn't, and builds a persistent understanding of you over time.
Zero-config, no external service, no API key, works out of the box.
Features
🧠 Brain-Like Memory Architecture
- - Hierarchical Memory: Exchanges → Summaries → Profile
- Importance Scoring: Each memory scored 0-1 based on significance
- Time Decay: Importance decreases over time (adjustable rate)
- Entity Tracking: Extracts and tracks people, places, things
- Semantic Chunking: Long content auto-split into manageable pieces
🔍 Smart Recall
- - Multi-Factor Scoring: Combines relevance, importance, AND recency
- Profile Injection: Builds and injects user profile periodically
- Context Window: Tracks conversation turns and manages memory refresh
💾 Intelligent Capture
- - Significance Detection: Only captures meaningful content
- Auto-Deduplication: Won't store the same thing twice
- Periodic Consolidation: Summarizes accumulated content when context grows long
- Category Detection: Auto-categorizes as preference, fact, decision, entity, skill
🗑️ Self-Maintaining
- - Auto-Pruning: Removes old/unimportant memories when limit reached
- Importance Protection: High-value memories kept longer
- Memory Stats: Track memory health and composition
Tools
| Tool | Description |
|---|
| INLINECODE0 | Search memories by natural language (semantic) |
| INLINECODE1 |
Manually save a specific memory |
|
local_memory_list | List all memories, optionally filtered by category |
|
local_memory_profile | View user profile (entities, preferences, facts) |
|
local_memory_stats | View memory statistics |
|
local_memory_recent | Get recently accessed memories |
|
local_memory_forget | Delete memory matching a query |
|
local_memory_wipe | Delete ALL memories (irreversible) |
How It Works
Memory Lifecycle
- 1. Capture → User + Assistant exchange
- Significance Assessment → Score based on patterns (decisions score high, greetings low)
- Storage → If significant enough, store with extracted entities and tags
- Importance Calculation → Based on category, length, entities, source
- Decay Over Time → Importance decreases exponentially
- Recall → On query, combine TF-IDF relevance + importance + recency
- Pruning → When max reached, lowest combined-score memories removed
Recall Scoring Formula
CODEBLOCK0
Significance Detection Patterns
| Pattern | Category | Weight |
|---|
| entschieden, geplant, wird, werden | decision | 0.30 |
| ich bin, mein, unser Unternehmen |
identity | 0.25 |
| bevorzug, immer, nie, prefer | preference | 0.25 |
| api_key, password, token | credential | 0.20 |
| skill, können, fähig | skill | 0.20 |
| projekt, build, deploy | project | 0.15 |
Configuration
CODEBLOCK1
| Option | Default | Description |
|---|
| INLINECODE8 | INLINECODE9 | Inject relevant memories before each turn |
| INLINECODE10 |
true | Auto-capture conversation exchanges |
|
captureInterval |
8 | Capture every N turns (higher = less storage) |
|
captureSignificantOnly |
true | Only capture significant content |
|
minSignificanceScore |
0.5 | Min score to capture (higher = stricter) |
|
profileFrequency |
15 | Inject profile every N turns (higher = less context) |
|
maxRecallResults |
5 | Max memories injected per turn |
|
similarityThreshold |
0.35 | Min relevance to inject |
|
maxMemoryInjections |
3 |
Max memories to show per recall |
|
contextBudget |
2000 |
Max chars of memory context injected |
|
maxMemories |
500 | Maximum memories to keep |
|
pruneOlderThanDays |
30 | Auto-delete memories older than N days |
|
decayRate |
0.05 | Importance decay speed |
|
importanceWeight |
0.25 | Weight of importance in scoring |
|
recencyWeight |
0.25 | Weight of recency in scoring |
|
relevanceWeight |
0.5 | Weight of TF-IDF relevance in scoring |
Data Storage
All memories stored locally in:
CODEBLOCK2
Default: INLINECODE40
Privacy
- - 100% Local: No data leaves your machine
- You Control: Auto-capture can be disabled
- Significance Filter: Won't store every random message
- No External APIs: No internet required
Requirements
- - OpenClaw 2026.1.29 or later
- Node.js (built-in TF-IDF, no external dependencies)
Tips
For Best Results
- 1. Let it run for a few days — memory improves over time
- Manually store important facts with INLINECODE41
- Check profile with
local_memory_profile periodically - Adjust
importanceWeight, recencyWeight, relevanceWeight to your preference
If Context Gets Long
- - Reduce
summariseThreshold to trigger earlier consolidation - Increase
decayRate to forget older stuff faster - Lower
maxMemories to prune more aggressively
Forgot Something?
- - Use
local_memory_forget query="what to forget" to delete - Use
local_memory_search to find what you're looking for
🧠 本地记忆插件 v0.4
为OpenClaw打造的类脑记忆系统。记住重要信息,遗忘无关内容,随时间推移构建对用户的持久理解。
零配置,无需外部服务,无需API密钥,开箱即用。
功能特性
🧠 类脑记忆架构
- - 分层记忆:对话 → 摘要 → 用户画像
- 重要性评分:基于重要程度对每条记忆进行0-1评分
- 时间衰减:重要性随时间递减(可调节速率)
- 实体追踪:提取并追踪人物、地点、事物
- 语义分块:长内容自动分割为可管理的片段
🔍 智能召回
- - 多因子评分:综合相关性、重要性和时效性
- 画像注入:定期构建并注入用户画像
- 上下文窗口:追踪对话轮次并管理记忆刷新
💾 智能捕获
- - 显著性检测:仅捕获有意义的内容
- 自动去重:不会重复存储相同信息
- 定期整合:上下文变长时自动汇总积累内容
- 类别检测:自动分类为偏好、事实、决策、实体、技能
🗑️ 自我维护
- - 自动修剪:达到上限时移除旧/不重要记忆
- 重要性保护:高价值记忆保留更长时间
- 记忆统计:追踪记忆健康状态和组成结构
工具
| 工具 | 描述 |
|---|
| localmemorysearch | 通过自然语言搜索记忆(语义搜索) |
| localmemorystore |
手动保存特定记忆 |
| local
memorylist | 列出所有记忆,可按类别筛选 |
| local
memoryprofile | 查看用户画像(实体、偏好、事实) |
| local
memorystats | 查看记忆统计信息 |
| local
memoryrecent | 获取最近访问的记忆 |
| local
memoryforget | 删除匹配查询的记忆 |
| local
memorywipe | 删除所有记忆(不可逆) |
工作原理
记忆生命周期
- 1. 捕获 → 用户+助手对话
- 显著性评估 → 基于模式评分(决策类评分高,问候类评分低)
- 存储 → 如果足够显著,连同提取的实体和标签一起存储
- 重要性计算 → 基于类别、长度、实体、来源
- 时间衰减 → 重要性呈指数级递减
- 召回 → 查询时,结合TF-IDF相关性+重要性+时效性
- 修剪 → 达到上限时,移除综合评分最低的记忆
召回评分公式
得分 = (相关性权重 × tfidf相似度)
+ (重要性权重 × 衰减后重要性)
+ (时效性权重 × 时效因子)
显著性检测模式
| 模式 | 类别 | 权重 |
|---|
| 决定、计划、将、会 | 决策 | 0.30 |
| 我是、我的、我们公司 |
身份 | 0.25 |
| 偏好、总是、从不、更喜欢 | 偏好 | 0.25 |
| api_key、密码、令牌 | 凭证 | 0.20 |
| 技能、能够、有能力 | 技能 | 0.20 |
| 项目、构建、部署 | 项目 | 0.15 |
配置
json
{
autoRecall: true,
autoCapture: true,
captureInterval: 8,
captureSignificantOnly: true,
minSignificanceScore: 0.5,
profileFrequency: 15,
includeProfileOnFirstTurn: true,
maxRecallResults: 5,
similarityThreshold: 0.35,
maxMemoryInjections: 3,
contextBudget: 2000,
maxMemories: 500,
pruneOlderThanDays: 30,
decayRate: 0.05,
chunkSize: 800,
importanceWeight: 0.25,
recencyWeight: 0.25,
relevanceWeight: 0.5
}
| 选项 | 默认值 | 描述 |
|---|
| autoRecall | true | 每次对话前注入相关记忆 |
| autoCapture |
true | 自动捕获对话内容 |
| captureInterval | 8 | 每N轮对话捕获一次(数值越大存储越少) |
| captureSignificantOnly | true | 仅捕获显著内容 |
| minSignificanceScore | 0.5 | 捕获的最低评分(越高越严格) |
| profileFrequency | 15 | 每N轮对话注入一次画像(数值越大上下文越少) |
| maxRecallResults | 5 | 每次对话注入的最大记忆数 |
| similarityThreshold | 0.35 | 注入的最低相关性 |
| maxMemoryInjections | 3 |
每次召回显示的最大记忆数 |
| contextBudget | 2000 |
注入记忆上下文的最大字符数 |
| maxMemories | 500 | 保留的最大记忆数 |
| pruneOlderThanDays | 30 | 自动删除超过N天的记忆 |
| decayRate | 0.05 | 重要性衰减速度 |
| importanceWeight | 0.25 | 评分中重要性的权重 |
| recencyWeight | 0.25 | 评分中时效性的权重 |
| relevanceWeight | 0.5 | 评分中TF-IDF相关性的权重 |
数据存储
所有记忆本地存储在:
~/.openclaw/memory/<容器标签>.json
默认路径:~/.openclaw/memory/openclawlocalmemory.json
隐私保护
- - 100%本地化:数据不会离开您的设备
- 您掌控一切:可禁用自动捕获功能
- 显著性过滤:不会存储每条随机消息
- 无外部API:无需互联网连接
系统要求
- - OpenClaw 2026.1.29 或更高版本
- Node.js(内置TF-IDF,无外部依赖)
使用技巧
最佳实践
- 1. 让它运行几天——记忆会随时间不断优化
- 使用 localmemorystore 手动存储重要事实
- 定期使用 localmemoryprofile 查看画像
- 根据个人偏好调整 importanceWeight、recencyWeight、relevanceWeight
上下文过长时
- - 降低 summariseThreshold 以触发更早的整合
- 增加 decayRate 以更快遗忘旧内容
- 降低 maxMemories 以更积极地修剪
忘记某件事?
- - 使用 localmemoryforget query=要忘记的内容 删除
- 使用 localmemorysearch 查找您要找的内容