feat: 添加分层记忆系统 (L0/L1/L2 Memory)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.7k
- Forks
- 719
- Avg merge
- 4h 30m
- Merged PRs (30d)
- 83
Description
功能描述
建议添加分层记忆系统,实现对话上下文的智能管理和压缩,解决长对话场景下的 token 消耗和上下文丢失问题。
背景与动机
当前对话系统在处理长对话时面临以下问题:
- 上下文窗口有限,无法保留完整的对话历史
- token 消耗随对话长度线性增长
- 重要信息可能被后续消息淹没
- 缺乏跨会话的长期记忆能力
提议的解决方案
实现三层记忆架构:
L0 - 原始消息层 (Raw Messages)
- 保留最近 N 条完整对话消息
- 用于即时上下文理解
- 默认保留 10-20 条消息
L1 - 会话摘要层 (Session Summary)
- 自动总结已完成对话段落
- 压缩比约 80-90%
- 在 L0 满时触发总结
- 保留关键决策、代码修改、用户偏好
L2 - 长期记忆层 (Long-term Memory)
- 跨会话持久化存储
- 提取重要事实、规则、用户习惯
- 支持手动编辑和查询
- 可导出为 memory.md
预期效果
- 减少 80%+ 的 token 消耗
- 保持长对话的连贯性
- 实现跨会话记忆延续
- 支持用户自定义记忆规则
参考实现
类似功能已在 NousResearch/hermes-agent#43955 中讨论,实现了 85% token 节省。
相关 Issue
- #590: 自动创建初始记忆 (初始化模板)
- 本 issue 关注完整的分层记忆系统实现
标签: enhancement, memory, feature-request
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing related issue #590 and the proposed L0, L1, and L2 requirements in this issue. Identify the existing conversation-context and persistence entry points before deciding the design. Done should include the three memory layers, cross-session storage, manual editing and querying, and export to memory.md, with the stated context and token-saving goals validated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- ai
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100