Repository navigation
Conversation
The host attributes synthesized user-role messages through `source.kind` — `plugin` for context injections and compaction checkpoints, `goal` for goal rounds, `session-reference` for recalls, `agent-message` for relays — and the GUI sidebar lists only `kind === "user"` (session-turn-outline). `/history` filtered by event type alone, so compaction checkpoints and injected context were listed as if the user had typed them. The persisted fallback also read the complete raw log first, which carries every non-surface injection. - ops.ts: `historyEntries()` + `isHumanUserMessage()` shared by both paths; legacy payloads without a `source` stay visible, so nothing real is hidden. - ops.ts: the persisted fallback now prefers `sessionQuery.readSurface()` (current model surface) and only then `readSession()` (complete raw log). - history-provenance.test.ts: live and cold cases — injected plugin/goal messages hidden, legacy payloads still visible, `readSurface` preferred over `readSession`. Verified with the repo's own gates on Node 22: `npm run build` clean, `npm test` 426/426 passing.
Owner
|
感谢排查和补测试。症状是对的: 这条没合,因为冷路径优先 已在 v0.9.6 用另一条实现落地:
因此关闭本 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.
症状
微信
/history会把压缩检查点、上下文插件注入、goal 续跑等合成 user 消息当成人话列出来(重启后走持久路径时更明显)。这些正文往往是被替换掉的整段历史,读起来像用户自己发的。根因
data.source.kind=user(真人)/plugin(上下文注入、压缩检查点,如plugin: "compact")/goal(目标续跑轮次)/session-reference(召回)/agent-message(子代理中继)。GUI 侧栏的规则就是只列kind === "user":packages/session/session-turn-outline/src/projection.ts:110。src/dsh/ops.ts的getSessionHistory()(:611)只按事件类型过滤(user/message+assistant/message),不看source.kind—— 内存路径(:621)与持久路径(:650)都一样。readSession()(完整原始日志)(:642),而原始日志包含全部非 surface 注入;宿主有readSurface()(当前模型面)时本可少踩这些事件。改法
src/dsh/ops.ts:抽出historyEntries()与isHumanUserMessage()两条路径共用;user/message仅在source.kind === "user"(或缺省)时列出 —— 没有source的老载荷照旧可见,不误伤真消息(data.message.source的嵌套形状也一并兼容)。SessionQuery增加readSurface?;持久回退顺序改为readSurface()(模型面,一次折叠)→readSession()(原始日志)→listEvents()(元数据兜底,保持原行为)。tests/history-provenance.test.ts(5 例):内存路径隐藏 plugin / goal 注入;无source的老载荷仍可见;冷路径优先readSurface且同样过滤(断言readSession未被调用);无 surface 时回落readSession。验证(本仓原生门禁,Node 22)
npm run build通过;npm test426/426 全绿(34 文件,相对 base +1 文件 +5 例)。src/还原成改动前、保留新测试 →tests/history-provenance.test.ts3 failed / 2 passed(失败的正是注入过滤与readSurface优先那三例),证明测试确实复现问题。边界说明(避免误读)
system/message事件类型,本就不在user/message里,本次不涉及。listEvents()兜底路径仍取不到文本(宿主该接口自 0.1.2 起不带data),行为与改动前一致,未扩大范围。source.kind === "user"),不引入本仓独有的判定。base =
main@12e0c90(#5 合并之后)。