feat(memo, runtime, web): 引入 run 边界记忆提取与语义去重,修复 Web 端 slash memo 指令#604
Merged
phantom5099 merged 6 commits into1024XEngineer:mainfrom May 10, 2026
Merged
feat(memo, runtime, web): 引入 run 边界记忆提取与语义去重,修复 Web 端 slash memo 指令#604phantom5099 merged 6 commits into1024XEngineer:mainfrom
phantom5099 merged 6 commits into1024XEngineer:mainfrom
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
背景
当前自动记忆提取存在两个问题:
提取窗口边界不够清晰
触发提取时可能混入历史会话消息,导致“本次 run 的事实”与“旧上下文”交叉,影响提取稳定性与可解释性。
去重能力偏弱
仅依赖近似“新增去重”,缺少对“已有自动提取记忆”的语义更新能力,容易重复沉淀或错过增量修正。
另外,Web 端
/memo、/remember、/forget在未建立 session 时交互较硬,并且对工具返回字段大小写兼容不完整(contentvsContent)。目标
create / update / skip。extractor_auto)的记忆,避免覆盖用户手动记忆。主要变更
1) Runtime:按 run 边界收集提取消息
对应影响:
internal/runtime/memo.gointernal/runtime/run.gointernal/runtime/session_mutation.gointernal/runtime/state.gointernal/runtime/runtime.go2) Context Projection:新增 memo 提取专用窗口构建
BuildMemoExtractionMessagesForModel(...),用于构造“完整 run + provider-safe”的提取上下文。对应影响:
internal/context/projection.go3) Memo:语义去重与受控更新
ExtractionAction:create | update | skipExtractionCandidate: 既有记忆快照(含 ref/scope/source/type/title/content)ExtractionDecision: 模型返回决策结构LLMExtractor新增ExtractDecisions(...),在 prompt 中注入 existing candidates,支持语义层面的合并/跳过判断。AutoExtractor优先走DecisionExtractor路径,按决策执行 create/update/skip。Service增加:autoExtractionCandidates(...):加载既有记忆候选updateAutoExtractIfAllowed(...):仅允许更新source=extractor_auto的记忆parseScopedTopicKey(...)等辅助逻辑对应影响:
internal/memo/types.gointernal/memo/llm_extractor.gointernal/memo/auto_extractor.gointernal/memo/service.gointernal/memo/auto_extractor.go(决策执行路径)4) Web:slash memo 指令修复
/memo、/remember、/forget对“先有 session”的硬依赖,提升可用性。payload.content与payload.Content。/remember、/forget参数校验,避免空参数误调用。对应影响:
web/src/components/chat/ChatInput.tsx测试
本 PR 增补并调整了关键测试,覆盖以下场景:
ExtractDecisions能读取 existing candidates 并返回 create/update/skip。/memo、/remember、/forget在无 session id 时可正常执行。payload.Content回退读取生效。涉及测试文件(节选):
internal/runtime/runtime_test.gointernal/context/projection_test.gointernal/memo/auto_extractor_test.gointernal/memo/llm_extractor_test.gointernal/app/bootstrap_test.goweb/src/components/chat/ChatInput.test.tsx兼容性与风险评估
update/skip语义分支(兼容旧格式默认 create)。变更总结
该 PR 把记忆提取从“可用”提升到“边界清晰 + 可语义维护”的状态: