Skip to content

记忆维护

记忆维护是指保持记忆系统健康、相关且在大小预算内的自动维护流程。PRX 定期运行维护任务来压缩、去重和清理记忆。

概述

没有维护的记忆存储会无限增长,随着不相关条目稀释搜索结果,回忆质量会下降。维护系统通过以下方式解决此问题:

  • 压缩 -- 将相关记忆组总结为简洁条目
  • 去重 -- 合并语义上重复的条目
  • 清理 -- 移除过期或低相关性的记忆
  • 归档 -- 将旧记忆移到冷存储

维护流水线

触发器(定时或阈值)


┌──────────────┐
│    去重      │──── 合并近似重复项
└──────┬───────┘

┌──────────────┐
│    压缩      │──── 总结相关条目
└──────┬───────┘

┌──────────────┐
│    清理      │──── 移除过期条目
└──────┬───────┘

┌──────────────┐
│    归档      │──── 移到冷存储
└──────────────┘

配置

toml
[memory.hygiene]
enabled = true
schedule = "daily"  # "hourly" | "daily" | "weekly"
max_entries = 10000
compaction_threshold = 100  # 当分组超过此大小时压缩
prune_after_days = 90
dedup_similarity_threshold = 0.95

手动触发

可以从 CLI 手动触发维护:

bash
prx memory compact
prx memory prune --older-than 90d
prx memory stats

相关页面

Released under the Apache-2.0 License.