Repository navigation
fix: skip draft-tail retry when the request itself asks for the summary (#2612) - #2619
ranxianglei merged 20 commits into
Conversation
…ary (ranxianglei#2612) Claude Code's own compaction (/compact, auto-compact) instructs the model to answer with a plain-text <analysis> + <summary> block and no tool call, so a compliant reply necessarily ends in </summary> - exactly the ranxianglei#2303 draft-tail shape. The empty-turn retry re-asks, the retry also complies, and the ranxianglei#870 in-band error surfaces to the client as "automatic compaction failed". Gate all three ranxianglei#2303 lanes on the request itself carrying the client summary instruction (two verbatim Claude Code phrases; a bare </summary> riding the history - e.g. a compress receipt - must NOT suppress the retry): - src/degenerate-turn.ts: requestExpectsProseSummary() plus lastUserSummaryInstruction() helper for the proxy lane. - src/plugin.ts chat pipe: !requestExpectsProseSummary(requestText). - src/plugin.ts responses pipe: same gate. - src/loop/core.ts draft-tail block: same gate via the last user message text. tests/issue2612-compaction-draft-tail.test.ts: 7 tests - helper unit tests (incl. near-miss and bare-tag false cases), no-retry with the instruction on both pipes and the loop, ranxianglei#2303 still enforced without the instruction.
[bot] 🏷 PR #2619(Fixes #2612)审查完成 — 可合(human merge) ① 是什么问题:Claude Code 自己的 /compact、auto-compact 在最后一条 user 消息里明确要求「纯文本回复, ② 什么原因导致的: ③ 影响范围与严重程度: ④ 怎么修复的:新增 ⑤ 是否有回归问题(逐项清点既有行为):
⑥ 是否破坏缓存:不涉及。前缀缓存、更新节流、增量游标均未触碰,仅本地重试判定条件变化。 ⑦ 是否改了设计方向:无。未采用原 issue 备选方案「本轮请求不含 compress 工具」——plugin 模式下 bili 本就不向请求注入 compress 工具(agent 自持压缩,KDD #7),该谓词对每一轮都为真,会永久禁用保护;短语匹配在三条通道上都成立,是正确选择。 ⑧ 是否引入了新的配置:无。 验证证据:本地 顺手小修(已推 PR 分支,独立标注提交 MINOR 发现(未动,留作者/owner 裁量):原提交 判定:方向正确、修法打在根因、回归覆盖充分、diff 整洁——可合。按 §7.4,改动横跨 |
|
CI note:
All ubuntu combos green on both master and this PR, and every other check passes. This looks like a pre-existing Windows-specific breakage introduced with #2610, not something from this branch (which only touches the draft-tail retry gates). |
[bot] 🏷 已独立核实,你的判断成立——两个红色 windows job 与本 PR 无关,判定不变:可合(human merge)。 核实过程与补充定位:
结论重申:本 PR 只动 draft-tail retry 门控(degenerate-turn/plugin/loop 三处 + 新测试),与上述 Windows 红 job 零交集;除该 pre-existing 失败外 CI 全绿。可合,请人工合并(§7.4 human 档位:跨三个模块且改变重试触发条件)。 |
…r-chars in plugin.ts)
[bot] 🏷 冲突解决 e581649 已独立核实——逐字共存属实,判定不变:可合(human merge)。按八问: ① 是什么问题:长期存活的 PR 分支与 master 冲突——master 的 #2756(answer-chars 门控)重写了本 PR #2612 所改的同一批 draft-tail 判定行(典型热文件竞争,§7.5 第 1 类)。 ② 什么原因导致的:两个 PR 各自向同一条 ③ 影响范围与严重程度:若解错,要么丢 #2612 门控(CC 压缩失败复现),要么丢 #2756 answerChars 条件(纯空白应答不再触发重试)。属高危解决点,故做了逐行验证而非只看测试。 ④ 怎么修复的:把 master 合入 PR 分支(e581649e,parents 09862cd+e7b94a2e0),三处判定取两侧意图的并集。 ⑤ 是否有回归问题:无。证明方式—— ⑥ 是否破坏缓存:不涉及。 ⑦ 是否改了设计方向:无——两套机制按各自设计意图共存。 ⑧ 是否引入了新的配置:无。 补充状态:CI 对 e581649 29/29 全绿(含 windows-latest 两组合——之前那个 pre-existing 红 job 已被 master 上的 #2631/#2634 EOL 修复治愈)。master 此后仅前进一个 #2763(raw-url compaction sniff,只动 |
[bot] 🏷 本轮「CI 红 3 例」已独立核实——归因成立,非本 PR 回归。判定不变:可合(human merge)。按八问: ① 是什么问题:PR 分支的一次同步合并(abd855500 "merge master")落在了 master 的一个中间坏点上——#2807(cross-protocol affinity)已引入回归、而其修复尚未合入的时间窗内,导致 CI 三个测试用例转红。 ② 什么原因导致的:时序窗,不是本分支代码。族谱证明: ③ 影响范围与严重程度:红点精确为 3 个用例(拉取红头 bb5a63d 的 ubuntu24 job 日志逐一比对): ④ 怎么修复的:把最新 master 合入 PR 分支得 21b99d7。小更正一处措辞:21b99d75 是 PR 分支 head,master tip 实为 cd02d2d(Merge #2826 release-v0.1.194)——即 21b99d7 的父提交;merge-base(PR, master)=cd02d2dc5,分支相对当前 master 零落后。 ⑤ 是否有回归问题:无。验证链——(a) 上述族谱三项断言全部实测通过;(b) 红用例集合与 #2807 文件域吻合、与本 PR 域不相交;(c) 本地 21b99d7 上定向跑 8 套件 59/59 全绿(issue2303 14 + issue2612 7 + issue2756-degenerate-gate 12 + compaction-archive 7 + loop-degenerate-retry 7 + 三个曾红的测试文件 12), ⑥ 是否破坏缓存:不涉及。 ⑦ 是否改了设计方向:无。 ⑧ 是否引入了新的配置:无。 CI 现状(21b99d751):29 项中 25 success,仅 4 个 test-matrix job 运行中,零失败。分支基于含 v0.1.194 的当前 master,无新冲突。可合,请人工合并。 |
Fixes #2612.
Problem
Since #2303 (0.1.188), a reply that ends with
</summary>/</analysis>and makes no tool call is treated as a stalled draft and re-issued once. Claude Code's own compaction (/compact, auto-compact) instructs the model in its final user message to answer with plain text only — "an<analysis>block followed by a<summary>block", "Wrap your summary in<summary></summary>tags" — so a compliant reply necessarily trips the #2303 detector. The retry re-asks, the retry also complies, and the #870 in-band error surfaces to the client as "automatic compaction failed". Every client compaction on thebili claudelane fails; the proxy lane (src/loop/core.ts) has the same structural risk.Fix
Skip the draft-tail retry when the request itself is a client summarization request. All three #2303 lanes get the same gate:
src/degenerate-turn.ts—requestExpectsProseSummary(requestText)matches the two verbatim Claude Code instruction phrases (not a bare<summary>tag, which also appears in bili compress receipts riding the history and must NOT suppress the retry);lastUserSummaryInstruction(messages)finds the last user message's text for the proxy lane.src/plugin.tschat pipe —draftTailverdict gains&& !requestExpectsProseSummary(requestText)(requestText is the shipped wire body text).src/plugin.tsresponses pipe — same gate.src/loop/core.tsdraft-tail block — same gate vialastUserSummaryInstruction(coreMessages).Tests
tests/issue2612-compaction-draft-tail.test.ts(7 tests, mirrors the #2303 fixtures):<summery>typo) and bare-tag-in-history false cases;</summary>in the history does not suppress the retry;tests/issue2303-draft-tail.test.tsstays 14/14 green;tsc --noEmitclean; branch based on current master (98fb91c).