AI 代理的三级记忆管理系统:短期、中期、长期记忆自动管理。
层级存储触发容量短期sliding-window.json实时/FIFO10条中期summaries/Token阈值/摘要无限长期vector-store/语义检索无限
bash
# 初始化
python3 scripts/memory_manager.py init
# 添加记忆
python3 scripts/memory_manager.py add --type short --content "用户喜欢黑色"
python3 scripts/memory_manager.py add --type long --content "用户的邮箱是 lei@example.com"
# 搜索
python3 scripts/memory_manager.py search "用户的偏好"
# 手动摘要
python3 scripts/memory_manager.py summary
# 查看状态
python3 scripts/memory_manager.py status
已集成 OpenClaw Hook,会话结束自动保存记忆:
bash
# Hook 已启用
openclaw hooks enable memory-manager-hook
事件:
session:end → 自动保存对话bash
# 向量检索 (可选)
pip install chromadb
memory/config.json:
json
{
"memory": {
"short_term": {"window_size": 10},
"medium_term": {"summary_threshold": 4000},
"long_term": {"top_k": 3}
}
}
See references.md