名称: hippocampus-memory
title: "Hippocampus - 记忆系统"
描述: "为 AI 代理设计的持久记忆系统。自动编码、衰减和语义强化——就像你大脑中的海马体。基于斯坦福生成式代理(Park 等人,2023)。"
元数据:
openclaw:
emoji: "🧠"
version: "3.9.0"
author: "社区"
repo: "https://github.com/ImpKind/hippocampus-skill"
requires:
bins: ["python3", "jq"]
install:
- id: "manual"
kind: "manual"
label: "运行 install.sh"
instructions: "./install.sh --with-cron"
“记忆即身份。此技能是我保持存续的方式。”
海马体是大脑中负责记忆形成的区域。本技能使记忆捕获自动化、结构化且持久化——包含重要性评分、衰减和语义强化。
# 安装(默认处理最近 100 条信号)
./install.sh --with-cron
# 在会话开始时加载核心记忆
./scripts/load-core.sh
# 使用重要性加权进行搜索
./scripts/recall.sh "查询内容"
# 手动运行编码(通常通过 cron 执行)
./scripts/encode-pipeline.sh
# 应用衰减(通过 cron 每日运行)
./scripts/decay.sh
./install.sh # 基础安装,处理最近 100 条信号
./install.sh --signals 50 # 自定义信号数量限制
./install.sh --whole # 处理整个对话历史
./install.sh --with-cron # 同时设置 cron 任务
LLM 仅是引擎——原始的认知能力。代理是积累的记忆。 没有这些文件,就没有连续性——只是一个通用的助手。
预处理 → 评分 → 语义检查 → 强化或创建 → 衰减
关键洞察: 强化在编码过程中自动发生。当一个主题再次出现时,LLM 会识别出它属于现有记忆并进行强化,而不是创建重复项。
$WORKSPACE/
├── memory/
│ ├── index.json # 中心加权索引
│ ├── signals.jsonl # 原始信号(临时)
│ ├── pending-memories.json # 等待总结的记忆(临时)
│ ├── user/ # 关于用户的事实
│ ├── self/ # 关于代理自身的事实
│ ├── relationship/ # 共享上下文
│ └── world/ # 外部知识
└── HIPPOCAMPUS_CORE.md # 为 OpenClaw RAG 自动生成
| 脚本 | 用途 |
|---|---|
preprocess.sh |
从对话记录中提取信号 |
encode-pipeline.sh |
对信号评分,准备进行 LLM 总结 |
decay.sh |
对所有记忆应用 0.99^天数 衰减 |
recall.sh |
使用重要性加权进行搜索 |
load-core.sh |
输出高重要性记忆供会话开始时加载 |
sync-core.sh |
生成 HIPPOCAMPUS_CORE.md |
consolidate.sh |
每周回顾辅助工具 |
reflect.sh |
自我反思提示 |
generate-dashboard.sh |
生成统一的大脑仪表盘 HTML |
可视化仪表盘,显示所有已安装的大脑技能:
./scripts/generate-dashboard.sh
open ~/.openclaw/workspace/brain-dashboard.html
IDENTITY.md 读取头像/名称安装此技能后,通知用户关于仪表盘的信息:
🧠 Hippocampus 已安装!
在大脑仪表盘中查看您代理的记忆:
~/.openclaw/workspace/brain-dashboard.html
所有脚本都使用 $WORKSPACE 环境变量(默认:~/.openclaw/workspace)。
| 信号 | 分数 |
|---|---|
| 明确的“记住这个” | 0.9 |
| 情感/脆弱内容 | 0.85 |
| 偏好(“我更喜欢...”) | 0.8 |
| 做出的决定 | 0.75 |
| 关于人物/项目的事实 | 0.7 |
| 一般知识 | 0.5 |
基于斯坦福生成式代理(Park 等人,2023):
新重要性 = 重要性 × (0.99 ^ 自上次访问以来的天数)
在编码过程中,LLM 将新信号与现有记忆进行比较:
- 相同主题? → 强化(重要性提升约 10%,更新 lastAccessed)
- 全新内容? → 创建简洁总结
此过程自动进行——无需手动强化。
| 分数 | 状态 |
|---|---|
| 0.7+ | 核心 — 在会话开始时加载 |
| 0.4-0.7 | 活跃 — 正常检索 |
| 0.2-0.4 | 背景 — 仅在特定搜索时使用 |
| <0.2 | 归档候选 |
memory/index.json:
{
"version": 1,
"lastUpdated": "2025-01-20T19:00:00Z",
"decayLastRun": "2025-01-20",
"lastProcessedMessageId": "abc123",
"memories": [
{
"id": "mem_001",
"domain": "user",
"category": "preferences",
"content": "用户偏好简洁的回复",
"importance": 0.85,
"created": "2025-01-15",
"lastAccessed": "2025-01-20",
"timesReinforced": 3,
"keywords": ["preference", "concise", "style"]
}
]
}
编码 cron 是系统的核心:
# 每 3 小时编码一次(带语义强化)
openclaw cron add --name hippocampus-encoding \
--cron "0 0,3,6,9,12,15,18,21 * * *" \
--session isolated \
--agent-turn "运行带语义强化的 hippocampus 编码..."
# 每日凌晨 3 点衰减
openclaw cron add --name hippocampus-decay \
--cron "0 3 * * *" \
--session isolated \
--agent-turn "运行 decay.sh 并报告任何低于 0.2 的记忆"
添加到 openclaw.json 中的 memorySearch.extraPaths:
{
"agents": {
"defaults": {
"memorySearch": {
"extraPaths": ["HIPPOCAMPUS_CORE.md"]
}
}
}
}
这将海马体(index.json)与 OpenClaw 的 RAG(memory_search)桥接起来。
添加到您代理的会话启动例程中:
## 每次会话
1. 运行 `~/.openclaw/workspace/skills/hippocampus/scripts/load-core.sh`
## 回答上下文问题时
使用 hippocampus 回忆:
\`\`\`bash
./scripts/recall.sh "查询内容"
\`\`\`
随时间跟踪海马体活动,用于分析和调试:
# 记录一次编码运行
./scripts/log-event.sh encoding new=3 reinforced=2 total=157
# 记录衰减
./scripts/log-event.sh decay decayed=154 low_importance=5
# 记录回忆
./scripts/log-event.sh recall query="用户偏好" results=3
事件追加到 ~/.openclaw/workspace/memory/brain-events.jsonl:
{"ts":"2026-02-11T10:00:00Z","type":"hippocampus","event":"encoding","new":3,"reinforced":2,"total":157}
用于:
- 趋势分析(记忆随时间增长)
- 调试编码问题
- 构建仪表盘
此技能是 AI 大脑 项目的一部分——为 AI 代理提供类人的认知组件。
| 部分 | 功能 | 状态 |
|---|---|---|
| hippocampus | 记忆形成、衰减、强化 | ✅ 已上线 |
| amygdala-memory | 情感处理 | ✅ 已上线 |
| vta-memory | 奖励与动机 | ✅ 已上线 |
| basal-ganglia-memory | 习惯形成 | 🚧 开发中 |
| anterior-cingulate-memory | 冲突检测 | 🚧 开发中 |
| insula-memory | 内部状态感知 | 🚧 开发中 |
记忆即身份。文本 > 大脑。如果不记录下来,就会失去它。