fix(harness): 连续会话压缩时会过滤上一轮摘要,导致原始用户意图丢失#2360
Open
CyberXavier wants to merge 1 commit into
Open
Conversation
- 保留先前摘要作为汇总输入以构建连续压缩,但排除它们避免重复提取 - 区分用于摘要的输入和用于内存刷新的输入,确保只刷新新压缩的消息 - 更新过滤逻辑使先前摘要参与下一次汇总但仍避免重复提取 - 添加完整的单元测试验证摘要消息的路由和处理行为
Contributor
Author
|
@jujn 我发现了一个上下文压缩时用户意图漂移的问题,提交了这份pr修复该问题,望您审批一下 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: #2359
过滤后的
prefix随后同时用于:这导致第二次及后续压缩无法看到上一轮摘要,实际行为变成:
而不是:
如果待压缩前缀只包含上一轮摘要,过滤后的前缀会变成空列表,
最终生成:
此时上一轮摘要中保留的会话目标、关键决策和后续计划会从模型上下文中丢失。
修复方案
根据用途分别构造摘要输入和长期记忆输入:
其中:
summaryInput保留上一轮摘要,用于生成累计摘要;flushInput过滤上一轮摘要,避免重复提取长期记忆;tail保持原有行为,继续保留未压缩的近期消息。修复后满足:
offloadMessages()的行为保持不变。该方法原本接收的就是完整messages,而不是过滤后的 prefix:因此本次修复只调整摘要生成和 memory flush 的输入,不改变会话归档语义。
测试覆盖
新增
ConversationCompactorTest,覆盖:No previous conversation history.;