Repository navigation
feat(memory): 补齐 L2 闭环检索与增量 FTS5,修复 source 静默升权并加固整理护栏 - #835
Merged
Merged
Conversation
- createMemoryTools 秘书模式不再产出 transcript_list / transcript_read,session_search 描述也不再指向它们; 秘书白名单本就不含这两个工具,agy 宿主工具与 secretaryReplay 直接用工厂产出,曾多暴露两个工具 - FTS5 search_tokens 在 CJK 与 ASCII 边界补空格,"用pnpm跑" 这类文本可按 pnpm 检索 - FTS5 只做整词/前缀匹配,零命中时回落原内存扫描,保住 ASCII 子串召回
J3n5en
enabled auto-merge (squash)
December 3, 2026 18:11
Owner
Author
|
评审修复已推到本分支(两个提交:先红测试,再修复)。阻断问题:
低优先级建议(本 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.
背景与目标
结合 Memory v2 现有评测基线与近期 Agent Memory 实践,本 PR 完成四项聚焦改进:
session_cursors与 L2 FTS5 索引,守住隐私边界并做悬空引用优雅降级;memory_write硬编码source: 'user_stated'导致observed笔记静默升权的 bug;主要改动
session_search透出after/before/sessionId过滤与rollout_summary高信息气味召回;新增transcript_list、transcript_read(按entryId或fromSeq展开前后文并剥离<long_term_memory>);memory_read透出derivedFrom,支持一跳核验原始对话;原始.jsonl已删除时transcript_read返回{ found: false, reason: 'session_deleted' };index.db升级至 schema v7,新增可重建的session_fts_files+session_turns_fts(中英文 2-gram + AND 优先回退 OR);删会话路径(agent.ts/projects.ts/bots.ts/btw.ts)同步调用forgetMemorySession清理游标、FTS5 行与 LRU 缓存。memory_write静默升权 bug:memory_write增加可选参数source?: 'observed' | 'user_stated';service.ts移除硬编码的source: 'user_stated'与allowResurrect: true,未传source时更新保留原source、新建默认'observed',非显式user_stated覆写已有高权威文档自动触发冲突护栏。detectCoreContentDrop增加反引号硬锚点 /[[wiki]]互链丢失检查,以及适用条件/否定约束(仅在/除非/严禁/never/...)丢失检查。transcript_list/transcript_read(已有session_list/session_read);memoryDispatchRecallEnabled改为缺省关闭(显式开启仍可用),避免与被派发会话自带的<long_term_memory>热前缀重复注入。评测与验证
.jsonl):0.397msvs 新 FTS50.917ms(p951.281ms)37.35ms(p9547.78ms) → 新 FTS53.00ms(p953.47ms),提速 ~13x83.66ms(p9588.69ms) → 新 FTS54.96ms(p956.18ms),提速 ~16xpnpm exec tsx eval/memory/run.ts --suite all:全量通过,0 回归(Gold 86 / Adversarial 63 / Scale 1500 / Perf 全部 OK)pnpm typecheck && pnpm lint:0 errorsvitest:8 个相关测试文件 227/227 全部通过