Skip to content

fix(memory): stop dropping end-topic turns that carry feedback from L1 - #548

Merged
origami-chen merged 3 commits into
MemTensor:v1.2.2from
Anson-Se:fix-end-topic-l1-capture
Oct 9, 2026
Merged

origami-chen merged 3 commits into
MemTensor:v1.2.2from
Anson-Se:fix-end-topic-l1-capture

Conversation

@Anson-Se

Copy link
Copy Markdown
Contributor

任务与行为

  • **关联记录:**Memmy 问题清单第 2 条"end_topic 的回合整轮不进 L1"。
  • **触发场景:**用户在同一轮里给反馈、定约定,又说结束,例如"很好,这个步骤很有用,谢谢。以后查看本地项目版本号都按这个步骤来。结束会话"。关系模型把这句判为 end_topic(置信度 1)。
  • **修改前:**收尾时挑选要做 L1 捕获的回合,只要是 end_topic 就整轮排除,任何配置下都一样。这一轮不生成 L1,也不写用户记忆;奖励输入里的最后一轮取不到这句话,满意度记为 0。
  • **修改后:**只有整句就是结束口令的回合("结束会话""不聊了",可带结尾标点)仍然排除。其他 end_topic 回合和普通回合走同一套捕获判定:配了摘要模型时,由模型决定是否生成 L1 和用户记忆,按捕获提示词,只有收尾语或致谢的回合不会生成 L1;没配模型时走原有的关键词预检。episode 关闭后,反思和奖励要等这一轮的捕获判定完成才排队,所以奖励能看到最后这句。

修改范围

  • Memory/src/service/session/session-turn-service.ts:captureEpisodeIncrementalSteps 的过滤条件从"任何 end_topic 回合"改为"纯结束口令"。rawTurnIsExcludedFromL1 去掉重复的 end_topic 判断:没配模型时,end_topic 只可能来自结束口令,这类回合在前一步已经排除。
  • Memory/tests/service/session/episode-relation.test.ts:新增混合消息用例,验证 L1、用户记忆和奖励目标都落在这一轮。原来断言"LLM 判定的 end_topic 不捕获"的用例改为:交给捕获判定后,只有收尾语的回合被拒,奖励目标退回上一轮。
  • 无前置依赖。不改接口和数据结构,不迁移数据;历史上被排除的回合不会补捕获。

验证证据

  • 分支 fix-end-topic-l1-capture,起点 d101fd58(即当前 memmy_1031/v1.2.0),提交 4f4e110c。提 PR 前已 fetch 并 merge 集成分支(Already up to date)。
  • 环境:macOS arm64,Node v25.1.0,npm 11.6.2。
  • 新增的混合消息用例在修改前失败(l1MemoryIds 为空),修改后通过。
  • npm run memory:test:105 个测试文件通过,1 个跳过(仅在 Windows 上运行的安装器集成测试);920 个用例通过。
  • npm run lint、npm run typecheck 通过。
  • git diff --check upstream/memmy_1031/v1.2.0...HEAD 无输出;交付差异只含上面两个文件。

已知限制

  • 关系模型仍可能把含反馈或指令的消息判为 end_topic。本 PR 不改判定,只保证这一轮不再被整轮丢掉。
  • 这一轮仍不做隐式反馈检测,现有逻辑只在切分新 episode 时检测。
  • 历史数据不回填。

🤖 Generated with Claude Code

…mand

A turn routed as end_topic used to be dropped from L1 capture as a whole,
so feedback, work conventions and instructions sent together with the
closing words never reached L1, user memory or the episode reward.

Only a bare end-topic command ("结束会话" / "不聊了") is still kept out of
L1. Every other end_topic turn now goes through the same capture decision
as a normal turn; the closed episode waits for that decision before
reflection and reward are queued.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 26, 2026 05:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

Reviewed changes and tests support the intended behavior with no unresolved blocking issues.

Review effort: Lite
Findings: None

What changed in this PR

Fixes end_topic handling so feedback-bearing closing turns can be captured for L1, user memory, and rewards while standalone closing commands remain excluded.

Changes:

  • Narrows filtering to standalone end-session commands.
  • Defers reward processing until capture decisions complete.
  • Adds regression coverage for mixed feedback and closing turns.
File Description
Memory/​tests/​service/​session/​episode-relation.test.ts Adds and updates capture and reward regression tests.
Memory/​src/​service/​session/​session-turn-service.ts Refines end-topic filtering and capture behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Anson-Se

Copy link
Copy Markdown
Contributor Author

@origami-chen 麻烦审核一下这个 PR:修复模型判为 end_topic 的回合整轮不进 L1 的问题,只保留对"结束会话""不聊了"这类纯结束口令的排除,细节见 PR 描述。

另外,这个 PR 从 fork 提交,Linux CLI installer 和 Windows Memory validation 两项检查在等维护者批准运行,也麻烦点一下 Approve and run workflows。谢谢!

@origami-chen
origami-chen requested review from origami-chen and removed request for ZongYue99 September 28, 2026 13:31
@origami-chen
origami-chen changed the base branch from memmy_1031/v1.2.0 to v1.2.2 October 9, 2026 08:33
const { db, service } = createTestService({
llm: createEndTopicCaptureLlm(calls, END_TOPIC_CONVENTION, {
l1: {
summary: END_TOPIC_CONVENTION,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里缺一个非空的title,会导致单测失败

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@origami-chen 已修复。v1.2.2 的捕获判定要求 l1 同时带非空的 title 和 summary,这个用例的桩数据只给了 summary,判定抛错,结束轮的 L1 停在 resolving。已在这里补上 title(0aa4be29)。

同时把 PR 的目标分支 v1.2.2 合进了任务分支(d8c1b218,无冲突),PR 的改动仍然只有这两个文件。

验证:合入 v1.2.2 后先复现了失败(expected { status: 'resolving' } to deeply equal { status: 'activated' });补上 title 后,episode-relation 的 21 个用例全部通过,npm run memory:test(1092 个用例)、npm run lint、npm run typecheck 均通过。麻烦再看一下。

Anson-Se and others added 2 commits October 9, 2026 20:37
v1.2.2 requires the turn capture decision to return a non-empty l1.title
together with l1.summary. The mixed feedback-and-closing test stub only
returned a summary, so the capture decision threw and the closing L1 stayed
in resolving instead of being activated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@origami-chen
origami-chen merged commit d396f16 into MemTensor:v1.2.2 Oct 9, 2026
5 checks passed
@Anson-Se
Anson-Se deleted the fix-end-topic-l1-capture branch October 11, 2026 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants