context collapse

Context Collapse 是第四层压缩策略,通过折叠旧对话轮次来减少 token 消耗。

设计理念

问题

长对话会累积大量历史消息:

  • 早期的对话可能不再相关

  • 重复的信息占用空间

  • 完整历史超出 token 预算

解决方案

将旧对话折叠为摘要:

[Earlier conversation: User asked about project structure, 
I analyzed 15 files and identified the main components...]

[Recent conversation preserved in full]

核心实现

基本折叠

智能摘要

折叠策略

滑动窗口

保留最近的对话,折叠旧的:

重要性评分

根据重要性决定是否折叠:

触发条件

Token 阈值

消息数量

折叠效果

示例

折叠前 (30 条消息,约 80K tokens):

折叠后 (11 条消息,约 30K tokens):

节省: 62.5% tokens

配置选项

用户配置

下一步