Repository navigation
fix(memory): 聊完整理失败静默丢弃,查不到「为什么没记住」(#239) - #240
Merged
Merged
Conversation
真机证据(报告者用量截图):「聊完记一下」1107 次失败 1005(91%), 「整理记忆/写印象」67 次失败 58(87%),用户表现是「从昨天开始一条记忆都没记住」。 两个问题(都不改「连续 5 次丢弃毒批」这条既有契约,llm-failure-backoff 守着): ① journal.putBack 失败放回却不更新 lastAt,而 due() 判 now-lastAt>=idleMs ⇒ 这批只要在 10 分钟前,每 30 秒 tick 都重新选中,把调用次数推高。 修法:putBack 接受退避时长 + 时间基准,写 retryAt;due() 尊重它。 ② 连续 5 次失败后丢弃是静默的 —— 没有任何地方留下记录,用户只能看到 「一条记忆都没记住」,查不到是模型挂了。修法:丢弃前记一条 kv digest.dropped (时间/通道/行数/最后一句),供诊断页与排障查。 红验证:去掉 retryAt 检查 → 测试红;去掉 recordDropped → 测试红。 既有 llm-failure-backoff(5m 指数退避 + 连续 5 次丢弃毒批)保持绿。
审查(独立 agent)抓到三处必须改: ① 回归 A(严重):retryAt 检查放在 due() 第一行,把「攒够 maxLines 就整理」 这条既有契约整个压掉 —— main 上绿、PR 上红(smoke-v08:52 守着)。 修法:只约束 idle 那一支,maxLines 分支不受退避影响。 ② 回归 B(中等):丢弃毒批时不清 retryAt。生产路径上 /memory/digest-now 直接调 digest() 绕过 due() 的退避,用户连点「现在整理」到第 5 次丢弃后, stale retryAt 会压住新消息最多 40 分钟。修法:take() 取走即清 retryAt。 ③ 留痕没人读:digest.dropped 之前只有测试读,等于没做。现在 /memory/state 回最近一条 dropped,设置页「聊完自动记」在有时显示 「有聊天没记成:时间 · 聊天 · N 行因模型连续失败 M 次被丢弃(最后一句…)」。 另外补 typecheck:ChatJournal.chats 的 @type 缺 retryAt(TS2339 两处)。 测试补 ⑥⑦ 两组,分别钉住回归 A 和 B(去掉对应修复各自变红)。
Closed
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.
Why
修复 #239。报告的用量截图:「聊完记一下」1107 次失败 1005(91%),「整理记忆/写印象」67 次失败 58(87%)。用户看到的是「从昨天开始一条记忆都没记住」。
What
两处,都不改既有的「连续 5 次失败丢弃毒批」契约(
test/llm-failure-backoff.mjs守着):journal.putBack放回 pending 时写retryAt(退避时长 + 时间基准),due()尊重它。以前放回不更新lastAt,而due()判now - lastAt >= idleMs,导致这批每 30 秒 tick 都被重新选中,把调用次数推高。digest.dropped(时间 / 通道 / 行数 / 最后一句)。以前丢弃是静默的,用户查不到是模型挂了。Verification
retryAt检查 → 红;去掉recordDropped→ 红。test/llm-failure-backoff.mjs(5m 指数退避 + 连续 5 次丢弃毒批)保持绿。Note
91% 的失败率本身还需要报告者那边确认模型/额度状况 —— 本 PR 修的是「失败被静默吞掉、看不出原因」这一层。
Refs #239