管理 AI 代理的三级记忆系统:短期(滑动窗口)、中期(自动摘要)、长期(向量检索)。
bash
# 初始化记忆系统
python3 scripts/memory_manager.py init
# 添加短期记忆
python3 scripts/memory_manager.py add --type short --content "用户喜欢黑色"
# 查询记忆
python3 scripts/memory_manager.py search "用户的偏好"
层级存储位置触发条件用途短期memory/sliding-window.json实时保持当前对话连贯中期memory/summaries/Token 阈值压缩历史,保留大意长期memory/vector-store/语义检索永久记忆,RAG
config/window_size(默认 10 条)memory/sliding-window.jsonconfig/summary_threshold(默认 4000)memory/summaries/YYYY-MM-DD.json创建 memory/config.yaml:
yaml
memory:
short_term:
enabled: true
window_size: 10
max_tokens: 2000
medium_term:
enabled: true
summary_threshold: 4000
summary_model: "glm-4-flash" # 或 gpt-3.5-turbo
long_term:
enabled: true
backend: "chromadb"
top_k: 3
min_relevance: 0.7
search 长期记忆,注入相关上下文See REFERENCES.md for complete command reference.