Skip to content

fix(cowork): keep highest-confidence implicit memories per turn#58

Open
yjh-Coder wants to merge 1 commit into
freestylefly:mainfrom
yjh-Coder:fix/implicit-memory-top-confidence
Open

fix(cowork): keep highest-confidence implicit memories per turn#58
yjh-Coder wants to merge 1 commit into
freestylefly:mainfrom
yjh-Coder:fix/implicit-memory-top-confidence

Conversation

@yjh-Coder

@yjh-Coder yjh-Coder commented Jun 25, 2026

Copy link
Copy Markdown

问题

隐式记忆提取每轮最多采纳 2 条。原实现按句子顺序依次 push,攒够 2 条就 break,于是当一轮命中超过两条候选时,留下来的是最先出现的,而不是置信度最高的

结果是:出现在前面的低置信度偏好,会挤掉出现在后面的高置信度身份事实。例如:

我喜欢深色主题。我养了一只猫。我叫张三。

旧行为会保留 我喜欢深色主题(0.88)+ 我养了一只猫(0.9),而丢掉 我叫张三(0.93),仅仅因为它排在最后。

修复

先收集全部合格候选,再按置信度降序排序后取前 N 条。Array.prototype.sort 是稳定排序,因此置信度相同的候选会保留原有的句子顺序。单轮去重与「每轮上限 2 条」的行为保持不变。

测试

新增同目录的 coworkMemoryExtractor.test.ts,覆盖:

  1. 排序修复(高置信度的身份事实即使出现在最后也能保留)
  2. 单轮内相同候选的去重

npx vitest run 通过;eslint 无告警。

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.
@yjh-Coder yjh-Coder force-pushed the fix/implicit-memory-top-confidence branch from 1d17d24 to c3faced Compare June 25, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant