Repository navigation
fix(chat): 长跑失忆根因——未摘要丢弃/门限自蒙蔽/工作记忆不可读 - #398
Merged
Merged
Conversation
主链(长跑失忆的真实机制): - compact 门限改为测量 un-budgeted 切片。此前 postAnchor 被 35% 预算压小后, 门限看到的是 summary+preAnchor+postAnchor≈55%,75% 阈值永远不触发;首次压缩后 锚点冻结,postAnchor 继续增长、每轮丢最老整轮且从未进摘要。现在门限会再次触发, 锚点前移,丢弃变为被摘要覆盖。 - postAnchor 丢弃通知改为真话(摘要不覆盖这些轮次),并在同一请求内附 DroppedRoundDigest(用户指令 + assistant 决策摘录,≤3k/24 行)。 - detached 锚点不再静默只留最近 60 条:在 context-summary 信封内写明丢弃条数 + 最近 40 条摘录。 - 缩量压缩改为摘要最老的 3/5,锚点只推进到实际覆盖边界;此前摘要最新 3/5 却把 锚点推到全量末尾,中间 2/5 永久消失。 - 摘要注入到 postAnchor 第一条真实用户消息,不再注入丢弃通知后被 fold 折回 pre-anchor 区域。 工作记忆/任务锚点: - WorkingMemoryLedger 用可读参数(path/command/query,复用 resolveToolDetail) 替代 8 位 SHA;哈希只做折叠身份。投递改为最新优先(紧邻保留尾部的轮次先到)。 - 任务锚点改为 live window 最新实质用户请求(薄跟进如“继续”不覆盖任务); 超长锚点头+尾裁剪,验收标准不再被截掉。 规则/提示词: - StandingContract 的绑定声明改由 dedupe 与预算实际接纳的交集决定;被预算丢掉的 规则块明确告知模型 NOT included(不再声称 BINDING)。 - Token Usage 测量型 prompt 构建不再改写 residentDailyFiles/覆盖 assembly 快照。 工具结果/召回/恢复: - ToolResultAging 保留头+尾(日志错误在尾部),keep 窗口按整轮对齐(并行调用不会 被切开),预算估计器补上 tool args 与图片。 - 排队消息 drain/中途插话时重建系统提示(锚点/日记门控/召回查询随新用户轮更新)。 - 召回只把实际渲染的 hit 标记已投递;中文 2 字查询可用;薄跟进回溯上一条实质消息。 - 尾预算一丢轮次即重新武装状态快照(plan/report/jobs),不再依赖 ledger 是否还有 未投递行。 - 已知失败闸门拒绝文案补参数摘要,模型知道被拒的是哪次调用。 验证: - 新增/更新 10 个回归测试文件;全量 6740 例(2 例 MockWebServer 环境性连接失败, 单独重跑通过)。 - 门禁:architecture policy(基线收紧 ChatViewModel 4616)、CJK、announced tools、 string refs、tool execution contract、schema drift 全绿。
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.
改了什么
长跑失忆的根因不是摘要质量,而是**「锚点之后、摘要之外」的 postAnchor 区域被预算直接丢弃,而 compact 门限测量的正是被同一个预算压小的切片**——首次压缩后门限永远不触发,锚点冻结,之后每轮丢的整轮从未进摘要,旧提示还声称「摘要已覆盖」。本 PR 修主链 + 6 处静默丢失点。
主链(P0)
contextTokensForPolicy改为测量 un-budgeted 切片;超阈值后压缩真正再次触发、锚点前移,丢弃变为被摘要覆盖。DroppedRoundDigest(用户指令 / assistant 决策,≤3k 字符、≤24 行)。工作记忆 / 任务锚点
规则 / 提示词
StandingContract的绑定声明改由 dedupe ∩ 预算实际接纳决定;被丢规则块明确告知NOT included。residentDailyFiles/ 覆盖 assembly 快照。工具结果 / 召回 / 恢复
ToolResultAging保留头+尾、keep 窗口按整轮对齐、预算估计器补 tool args 与图片。怎么验证的
PostAnchorBudgetTest、DroppedRoundDigestTest、CompactGateArchitectureTest、CompactDetachedAnchorTest、CompactResilienceTest、ToolResultAgingTest、WorkingMemoryLedgerTest、TaskAnchorTest、StandingContractTest、MemoryRecallEngineBatchTest、ToolFailureMemoryTest)。origin/main(f91708e4,fix(chat): 会话规则遵守的结构性修复——绑定信封/预算不静默丢弃/解耦记忆开关/三通道继承 #397 同域修复已合并)。风险与回滚
revert;新增文件均可独立删除,无 schema 变更。详细根因/机制对照见
docs/context-memory-reliability-2026-11-19.md。