fix(cowork): keep highest-confidence implicit memories per turn#58
Open
yjh-Coder wants to merge 1 commit into
Open
fix(cowork): keep highest-confidence implicit memories per turn#58yjh-Coder wants to merge 1 commit into
yjh-Coder wants to merge 1 commit into
Conversation
The implicit memory extractor capped each turn at 2 additions by pushing candidates in sentence order and breaking once the cap was reached. When a turn contained more than two qualifying candidates, the survivors were the first ones seen rather than the most valuable ones — a low-confidence preference appearing early could crowd out a high-confidence profile fact appearing later in the same message. Collect all qualifying candidates first, then sort by confidence descending (Array.prototype.sort is stable, so ties keep their original order) and take the top N. Adds co-located tests covering the ordering fix and the single-turn dedup behavior.
1d17d24 to
c3faced
Compare
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.
问题
隐式记忆提取每轮最多采纳 2 条。原实现按句子顺序依次 push,攒够 2 条就
break,于是当一轮命中超过两条候选时,留下来的是最先出现的,而不是置信度最高的。结果是:出现在前面的低置信度偏好,会挤掉出现在后面的高置信度身份事实。例如:
旧行为会保留
我喜欢深色主题(0.88)+我养了一只猫(0.9),而丢掉我叫张三(0.93),仅仅因为它排在最后。修复
先收集全部合格候选,再按置信度降序排序后取前 N 条。
Array.prototype.sort是稳定排序,因此置信度相同的候选会保留原有的句子顺序。单轮去重与「每轮上限 2 条」的行为保持不变。测试
新增同目录的
coworkMemoryExtractor.test.ts,覆盖:npx vitest run通过;eslint无告警。