mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 05:30:22 +08:00
YG 实测反馈 v3 规则下中途发消息走了 anchor,不是预期的 full。 根因:cordis dsh-agent-loop step() 顺序是 turn/start → prepare → assemble → user/message append → request assemble 发生在 user/message append 之前,中途发消息的那次 assemble 时 session 末尾只有 turn/start,新的真实 user/message 还没进来。原 scanUserTurn 只找最后 一个真实 user/message,扫到的是 **旧 turn** 的,afterCount 积得很大 → 误判 tool-loop → anchor。 v4 修法: - scanUserTurn 追踪 latestTurnStartSeq 和 hasAnyUserAfterLatestStart (真实或 内部 kind=plugin/dsh-purge 都算)。 - 如果 "最新 turn/start 之后没有任何 user/message append" → newTurn=true → shouldInjectAssembly 返回 full lastRole=turn-start。 - 如果 continuation (agent.followup) 已经 append 了 kind=dsh-purge 的 user/message 在 turn/start 之后 → hasAnyUserAfterLatestStart=true → 不触发 newTurn → 走正常 afterCount,一般是 tool-loop 的 anchor,符合 "agent 自己继续不是 user 发话"。 现在的 lastRole 枚举:retry / turn-start / no-user / user / task-decl / tool-loop 前五个都是 full,只有 tool-loop 是 anchor。