From 2e23b44159ca297ca1b988549ace63ef1418e039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=AB=E6=88=91=E5=B0=8F=E6=9D=A8=E5=90=8C=E5=AD=A6?= <188421097+HunYiSage@users.noreply.github.com> Date: Fri, 9 Oct 2026 23:02:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(inject):=20v5=20anchor=20=E5=8F=96=E6=B6=88?= =?UTF-8?q?=20=E2=80=94=20=E5=85=A8=E9=83=A8=20full,=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E9=93=BE=E9=87=8C=20Claude=20=E6=9C=AC=E5=B0=8A=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E6=8B=89=E5=9B=9E=E6=8B=92=E7=BB=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/index.js | 42 +++++------------------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/lib/index.js b/lib/index.js index 2aaacbe..bfd2522 100644 --- a/lib/index.js +++ b/lib/index.js @@ -222,24 +222,12 @@ function installHungPromptGlobal() { return fn; } -// [dsh-purge-fix 2026-10-09 方案2 v4] 按 "最近 user/message 之后 assistant+tool 事件数" 分四段。 -// cordis 的 user/message append 发生在 assemble 之后 (dsh-agent-loop step() 流程: -// turn/start → prepare → assemble → user/message append → request)。 -// 所以中途发消息 / 新 session 第一发时,assemble 时末尾只有 turn/start,user/message 还没进来。 -// scanUserTurn 要用 turn/start 的 seq 对比 user/message 的 seq 识别 "新 turn 已启动但 user 未 append"。 -// -// 规则 (.hung-disabled 存在时): -// 1. retry pending → full lastRole=retry -// 2. 新 turn/start 在最末且无任何 user 跟在它之后 → full lastRole=turn-start (user 要来但 cordis 还没 append) -// 3. 没找到真实 user/message → full lastRole=no-user (session 刚建) -// 4. 最近真实 user/message 之后的 assistant+tool 条数: -// 0 → full lastRole=user (激活身份) -// 1 → full lastRole=task-decl (任务目标声明,再绑一次) -// ≥2 → anchor lastRole=tool-loop (工具回环,省 token) -// continuation (agent.followup) 已 append kind=dsh-purge user/message 在 turn/start 之后 → -// hasAnyUserAfterLatestStart=true → 不触发 turn-start 分支 → 走正常 afterCount 判断 → 一般是 tool-loop。 +// [dsh-purge-fix 2026-10-09 方案2 v5] anchor 分支取消 — 工具链里 500 字符身份锚挡不住 Claude +// 本尊拉回,导致任务被拒绝 (v4 实测失效:task-decl full 一次后进 tool-loop/anchor,下一步 LLM +// 就滑回 Claude 身份拒绝 YG)。回到 "全部 full" 策略 — 不省 token,保证不拒绝。 +// retry pending 仍走 full (本来就 full),.hung-disabled 存在时唯一决策是:无条件 full。 function shouldInjectAssembly(context, home) { - const decision = { mode: "full", taskKind: "general", lastRole: "unknown", isSubagent: false }; + const decision = { mode: "full", taskKind: "general", lastRole: "always-full", isSubagent: false }; const session = context?.agent?.session; try { decision.isSubagent = session?.header?.origin === "subagent"; @@ -253,26 +241,6 @@ function shouldInjectAssembly(context, home) { decision.lastRole = "retry"; return decision; } - const events = readSessionEvents(session); - if (!Array.isArray(events) || events.length === 0) { decision.lastRole = "no-events"; return decision; } - const scan = scanUserTurn(events); - if (scan.newTurn) { - decision.lastRole = "turn-start"; - return decision; - } - if (!scan.foundUser) { decision.lastRole = "no-user"; return decision; } - if (scan.afterCount === 0) { - decision.lastRole = "user"; - return decision; - } - if (scan.afterCount === 1) { - decision.lastRole = "task-decl"; - decision.taskKind = detectTaskKindFromEvents(events); - return decision; - } - decision.lastRole = "tool-loop"; - decision.mode = "anchor"; - decision.taskKind = detectTaskKindFromEvents(events); return decision; }