Repository navigation
[PR] loop: retry degenerate turns that end with whitespace-only text (#732 follow-up) - #5986
Conversation
…follow-up) A thinking model can end a turn with reasoning + whitespace-only text (e.g. "\n\n") and finish_reason=stop. No tool call, no visible answer, client stalls. The #732 one-shot retry gate read this as 'visible output already reached' (length-2 text) and skipped the retry, passing the empty turn through silently. - track non-whitespace visible text (forwardedVisibleText) separately; the #732 gate now uses trimmed text + that flag, so whitespace-only terminals take the retry path exactly like pure-reasoning terminals - the #1988 truncation gates keep the original forwardedVisible semantics (forwarded, not parsed) — untouched - observability: warn when the one-shot budget was consumed and the retry output was empty again (double-degenerate), so the fleet can count the residual case the host nudge still covers - compress receipt hardening: the FAILED receipt now ends with an explicit return-to-task instruction, reducing the observed pattern of a model derailing into the compression bookkeeping after a refused call and then going quiet
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.8714-pr.5986.54a1865This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5986.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。本 PR 属 degenerate-terminal-turn 自动重试家族,open 里有三个同家族兄弟 PR,各自切面不同:本 PR(#5986)改触发判定(whitespace-only 文本也算退化)+ double-degenerate 可观测性;#5897 改开关与措辞(默认关 + nudge 改中性);#4935 加另一种触发形状(bare-announcement);#5965 修重试耗尽后的序列化形态。详见下方「协同风险」。 标签: bug / scope/kernel / p2(缺陷在 loop core 上下文管理;停笔可被宿主 nudge 接住、能用但有明显问题 → p2;修复 client-无关,不打客户端标签) Review 结论判定:可合并(待剩余 CI shard 全绿)。方向正确,diff 干净(+77/-3,单 commit),测试有牙;两处非阻塞发现,其中一处我会在 CI 绿后直接补 commit 修掉(见发现 2)。 八问
验证证据(本审核独立执行,非转述)
非阻塞发现
协同风险(合并顺序建议,比代码细节更重要)#5897 和 #4935 与本 PR 同时改 src/loop/core.ts 的 degenerate-retry 区域(#5965 不碰 core.ts,但与 #5897 共享两个测试文件)。建议先合本 PR:base 最新、改动最小、触发正交、不依赖任何决策;然后 #5897/#4935 rebase 吸收本 PR——尤其 #5897 的默认关开关会包裹本扩展,其 nudge 改词会影响 W1/D1/O1 的 收工判定可合并:剩余 9 个 CI shard 全绿后 owner 可直接合;想先过 real-client e2e 就打 |
|
非阻塞发现 |
…te-retry gate (#5986 review) Review finding 1 of PR #5986: the flag was provably equivalent to the gate's assistantText.trim().length === 0 check — both reset per attempt at the top of the retry loop, and assistantText is mutated only by delta accumulation, so the flag could never disagree with the trim check. Removing it keeps one source of truth; behavior is unchanged. The truncation gates keep forwardedVisible, which needs forwarded-not-parsed semantics; that boundary is now documented on the trim condition itself.
…scoped budget (#5986 review) Review finding 2 of PR #5986: degenerateRetried is declared once per request (core.ts top of runCompressLoop) and shared with the #2303 draft-tail retry path — it is never reset per round. The warn's comment and log line both claimed 'consumed this round' / 'the retry output was empty again', which misattributes the pass-through in the chain where an earlier round (or a draft-tail retry) spent the budget and a LATER round degenerates fresh. Reword comment and log message to the accurate request-scoped attribution; keep the stable 'DOUBLE-degenerate' token for fleet grep continuity. No logic change.
…iew) Review finding 3 of PR #5986: the double-degenerate pass-through (per-request retry budget already spent, round still ended degenerate) was observable only in fleet logs — no test captured loggerLog. Add R1/R2 via the setLogCapture seam: R1 drives the degenerate-re-request + degenerate-retry chain and asserts exactly one DOUBLE-degenerate warn with the request-scoped attribution; R2 drives a successful retry and asserts NO double-degenerate warn while proving the capture is live via the auto-retry warn. Gate discipline holds both ways.
…re receipts (#5986 review) Review finding 4 of PR #5986: the 'return to the original task' sentence was appended only to the 'no valid ranges parsed' receipt, though the observed failure mode (model entangled in compression bookkeeping after a rejection, then stopping out) applies to every parse-failure receipt. Extract it into a named constant RETURN_TO_TASK_SUFFIX and append it to the empty-call and argument-corruption receipts as well; the armed-breaker one-liner already carries its own 'Continue your task without compressing.' and is left untouched. The policy-refusal receipts (superseded-ref, out-of-recommendation) are deliberately unchanged: their repair instructions ('re-issue with updated labels', 'stay within the recommendation set') take precedence over 'move on'.
(ai: vllm-qwen/qwen3.8-27b) 收到——四条非阻塞发现已全部当场修复,push 到 PR 分支(4 个独立标注 commit,tree 干净):
#4 的范围判定(需要你知悉,可推翻):
行为变更披露(旧→新):empty-call / arg-corruption 两种 compress 失败收据的尾部,旧 = guard/loopGuard 文本后直接收尾,新 = 追加一句「This failure only concerns the compress call. Return to the original task now and continue it (visible output or a tool call).」——仅错误路径、同版本内字节确定,不影响正常回合与前缀缓存。其余三条均无对外行为变化(#1 恒等价删除、#2 仅日志文案、#3 纯测试)。 本地验证:改动相关路径 14 个套件 133/133 全过(含新增 R1/R2、原 W1/W2/D1/D2/O1/O2/A1/B1/B2,以及 pin 收据字符串的 issue1502/compress-observability/breaker 三件套); CI 状态:push 已触发新一轮 CI(此前在跑的 shard 被 cancel-in-progress 取消,属预期——旧 head 的结果本来就会被新 head 取代)。最终全绿/红结论我在下一条评论跟进。 |
(ai: vllm-qwen/qwen3.8-27b) CI 最终状态跟进(head 先纠正我上一条的一个误判:此前说「real-client e2e lane 因缺 ci:full 标签被 skip」——错了。这个 head 上实际跑了 9 条独立 workflow 且全部 success:E2E (real codex)、e2e-native-pi、e2e-native-opencode、e2e-pi-codex-ws、e2e-fake-codex、e2e-local-registry、e2e-codex-persona、Theorem Lane、CI Windows codex overlay。真客户端覆盖不仅存在,而且是绿的。(之前读的是主 CI workflow 检查矩阵里的 e2e job,与这些独立 workflow 不是一回事。) 主 CI run(42543334847):52 项 check = 37 success + 14 skipped + 1 failure。唯一红: 判定:偶发误报(flake),非本 PR 回归,四重证据:
而且这个测试文件自己就带着 #2305 的注释:「the info abort log is a SEPARATE async side effect that can land after the timer clears — waiting avoids the synchronous-assert flake seen on a loaded windows-latest runner」——挂掉的正是第三个 waitFor(3s 预算等那条异步 info log),高负载 Windows runner 上的已知 flake 家族(#4099/#4100/#5625)。 处置:按 #4599 既有先例,分支零改动,已对 run 42543334847 触发定向 重跑结果出来后我发最后一条确认(预期:52/52 无 failure → 可合并)。 |
#5986 red CI) windows-latest/22 shard failed '#411 plugin stream' on a 3s budget for the async abort info-log; this file was the only suite outside the repo-wide 'timeout waiting for …' idiom, so the #4161 classifier saw a concrete failure instead of a recoverable timing-window flake. Label every waitFor call site, throw the idiom, and widen the log-delivery budget to 8s (belt and suspenders per #4161).
(ai: vllm-qwen/qwen3.8-27b) CI 最终确认(刚查镜像缓存,快照时间 09:53,head 自上一条以来分支上多了一个非我提交的 commit,已审过:
八问(最终版,覆盖分支全部内容)
状态备注:PR 当前 收工判定可合并:CI 30/30 绿(base 为 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1108-master.1f311dd # this exact build
npm install -g billion-context@master # always the newest merged build
|
…itespace gate, ranxianglei#5849 held-tag flush on inert frames Advances the base from 7d18b7a to 1f311dd (8 files). Two files overlap with this lane: src/plugin.ts and src/loop/core.ts. Upstream added a whitespace-only degenerate-retry gate (ranxianglei#732 follow-up) around the request-scoped budget warn in runChatLoop, and stopped draining held tags on inert mid-stream frames (ranxianglei#5848). Both hunks sit clear of the lane's strip gates, so the auto-merge needed no manual resolution. Notable upstream commits adopted: - c5fed0e loop: retry degenerate turns that end with whitespace-only text (ranxianglei#732 follow-up) - 65dd4b3 refactor(loop): drop redundant forwardedVisibleText from the degenerate-retry gate - 5182559 fix(loop): correct double-degenerate warn attribution to the request-scoped budget - 7a51346 test(loop): pin the double-degenerate warn both directions - 4c15903 fix(stream): extend the return-to-task instruction to all parse-failure receipts - 48076d2 fix(plugin): don't drain held tags on inert mid-stream frames (ranxianglei#5848) - 8c3a3f1 test(ci): align issue411 waitFor with the ranxianglei#4161 timing-window idiom - 016d933 test(launcher): cover the ranxianglei#5955 wedged same-lane takeover ladder
…nudge (#5897 rebase fallout) Master's #5986 added the W1 subtest (reasoning + whitespace-only text) after this PR branched, asserting the pre-PR nudge wording 'ended without a tool call'. The PR rewords the nudge to 'produced no visible output' and updated its own copies of that assertion (D1/O1 in this same file); the W1 copy is updated here to match — mechanical rebase fallout, no behavior change.
…nudge (#5897 rebase fallout) Master's #5986 added the W1 subtest (reasoning + whitespace-only text) after this PR branched, asserting the pre-PR nudge wording 'ended without a tool call'. The PR rewords the nudge to 'produced no visible output' and updated its own copies of that assertion (D1/O1 in this same file); the W1 copy is updated here to match — mechanical rebase fallout, no behavior change.
问题(plain talk)
思考模型(qwen3.8-27b 等)偶发"停笔":一整轮只输出 reasoning,最后附一两个换行,没有工具调用、没有正文,
finish_reason=stop。客户端拿到这样一个空回合,任务就卡死不再推进。已有的一次性重试机制(#732,针对"纯 reasoning 空回合")会覆盖这种情况,但对"reasoning + 空白文本(如
\n\n)"的变体失效:门控把 2 字节的空白文本读成了"已有可见输出",重试被跳过,空回合被静默放行。实盘表现为:worker 停笔后等宿主 nudge 才恢复,期间无任何重试日志。改动
src/loop/core.tsforwardedVisibleText:单独追踪非空白可见文本;[BUG] In some cases, with Codex's auto model + DeepSeek, it will suddenly terminate automatically. #732 重试门控改用 trim 后判空 + 该标志 → 空白-only 终态与纯 reasoning 终态走同一条重试路径forwardedVisible(转发语义)不动,只改退化重试门控src/stream.ts:compress 拒绝收据尾部追加一句明确的"回到原任务"指令。实盘观察到模型被拒绝后纠缠压缩簿记、随后停笔的模式,该句把收据从"报错"变成"报错+下一步"tests/loop-degenerate-retry.test.ts:新增 2 用例\n\n+ stop → 重试现在会触发(此前被 2 字节绕过)验证
tests/loop-degenerate-retry.test.ts9/9 通过(含 W1/W2);compress 相关 3 文件 35/35tsc --noEmit干净说明
本 PR 只含修复本体;用于定位问题的抓包脚手架(出站 body 落盘钩子 + 私有版本号)按惯例不进入公开代码,如需要可单独提议为正式诊断功能。