Repository navigation
[PR] fix: hold round>=2 signed thinking off the wire until its signature lands (#4679) - #4712
ranxianglei wants to merge 5 commits into
Conversation
…ands (#4679) On an Anthropic-format upstream that signs thinking blocks, a cut inside bili's own re-request round (round >= 2, after a proxy tool like compress committed work) stranded the client with an unsigned thinking block and a terminal error: round-2 thinking streamed live, the signature never arrived, and #2501 correctly barred the only re-fetch that could have healed it. Root cause: in rounds > 1 the adapter held only the thinking START frame off the wire (#2501) but forwarded every payload delta live. A pre-signature cut left an open unsigned block the client could not replay (round 1 committed visible text; the round-2 request is bili's own, not the client's). Fix: hand the loop's signing evidence (historyHasSignedThinking || sawSignedThinkingThisTurn, anthropic lane) into parseStream as ParseStreamOpts.upstreamSignsThinking. In rounds > 1 on an evidenced signing upstream the adapter holds the WHOLE block (start + payload) off the wire until its signature arrives, flushing start+payload+signature together when it lands and discarding on a signature-less stop. A pre-signature cut leaves zero client state so the #413 blind re-fetch fires and heals the turn. #2501's gate and round-1 behavior are untouched; with no evidence the relay streams thinking live exactly as before (no latency regression). Tests: tests/anthropic-round2-thinking-hold.test.ts - T1 history-evidence heal (fails on master), T2 relay no-regression guard, T3 turn-level-evidence heal (fails on master).
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.5791-pr.4712.1c22c4eThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4712.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…ment #4316 PR3/3 (restampRefsToLedger) re-homes citation numbers once on every full-mode cold load; goldens pinning exact ref numbers are born-red. Re-pin the 7 storage-lane tests (engine-proofs x6 + orphan-recovery x1) modulo that renumbering — zero production code touched. - golden-storage-drive.ts: per-turn citation-normalized digest (shaCiteNorm) and state digest modulo stripOneTimeAlignment (stateDigestAligned); the deep-sort helper is hoisted into golden-canonical.ts for sharing. - corrupt-index-child.ts: new stripOneTimeAlignment normalizer — strips the refLedgerAligned stamp and re-homes refs onto canonical raw-id order so a clean full-mode read and the legacy fallback load compare equal. - storage-engine-proofs.test.ts: wire legs assert shaCiteNorm equality vs the legacy restart leg and the committed goldens; state legs assert stateDigestAligned; rollback leg now spells BILI_STORAGE_UNIFIED=legacy explicitly (#3818 flip: absent resolves to full, deleting the env would vacate the legacy path). - storage-orphan-recovery.test.ts: pins the content-addressable byRaw->byRef round-trip instead of a counter-era m00003 literal. - golden/storage-render/*.json regenerated with shaCiteNorm/stateDigestAligned. Converges the master-red storage-lane family (#4599 plan A, owner directive).
(ai: vllm-qwen/qwen3.8-27b) 查重结论:重复 #4681(先到),建议关闭本 PR。 同症状(round≥2 在签名到达前被切断 → 客户端留下未签名 thinking 块 + 不可恢复的终态错误)、同机制(把签名证据传入 parseStream;有证据的 signing upstream 上把 round≥2 整个 thinking 块(start+payload)hold 在 wire 外直到 signature 到达,原子 flush;无签名的 stop 整块丢弃 → 签名前零客户端状态,#413 盲重取自然愈合)、同根因(#2501 在 rounds>1 只 hold start frame、payload live 转发)。#4681 创建于 11:08Z,本 PR 13:12Z,两者都修 #4679。按先来后到保留 #4681。(agent 无关闭权、镜像标签接口当前不可用打不上 独立审核结论(非照抄任一版本描述):两个版本代码质量都过关,均未发现回归。 本 head 本地逐项验证:新测试文件 3/3 绿;同一文件放到裸 master 上 T1/T3 红、T2 绿(与 PR 声称一致,回归钉有牙);相邻套件全绿(#2501 门 5、thinking-replay 3、#1960 verbatim 3、loop-compress 15、round2-stream 3)。既有行为清点:round-1 路径与 #2501 门不变;unsigned relay(无证据)照旧 live 流(T2 钉住);有证据时块最终内容(text+signature)逐字节一致,仅 SSE delta 切分形态与到达时序变化(incremental→burst,PR 已披露);accounting 通道对 withheld 文本的记录不变;其他 adapter 忽略 opts。残留洞(无证据的那一轮仍是旧行为)PR 已如实披露,取舍合理(否则要 hold 每个 relay 的 thinking 到块尾,unsigned GLM/DeepSeek 类 relay 吃延迟回归)。两版实现小差异:本版 export ParseStreamOpts 且在 core 按 protocol 门控,#4681 保持内部接口、adapter 内自武装——均可接受,不影响重复判定。#4681 也已在其自身 head 本地验证(npm ci + 重建 kernel 后)4/4 绿。 CI 红分账:继承性 master 级 born-red,与本 PR 无关。 7 个红分片(u22s2/s3、u24s2/s3、w22s1/s3/s4)全部落在 #4599 floor 20 清单在册的 born-red 族(storage-render golden ×4 wire 的 metadata digest 漂移 + storage-engine-proofs ×6 + plugin-fork ×1)。已在裸 master HEAD 4d37fea 本地逐字节复现(chat stateDigest 9f1b8258a916fcf6 vs golden e149c301f382438e,metadata 2198f47054c8acae vs 55733fb81ccf7d69,state-key divergence: none);本 diff 只碰 src/loop/* + 一个新测试文件,与失败路径零重叠。#4681 命中同一族 7 片,且其 base 已含哨兵 golden regen 12e7753 仍红;ci-fixes 当前无领先 master 的提交(merge 为 no-op),哨兵今日已达限流待 owner 裁决(#4599 floors 146/168)。 八问
判定:不合入本 PR —— 后到的重复项,按先来后到保留 #4681(其代码同样过审、测试本地 4/4 绿、CI 红同源继承)。请 owner 打 |
(ai: vllm-qwen/qwen3.8-27b) 结论摘要(auto-fix lane attempt 1/2)7 个红 shard 全部是 master 继承性红(born-red 集群),与本 PR 的代码改动无关。已按 #4599 协议把 八问:
剩余红的诚实披露(新 head CI 重跑后的预期):转绿——u22s2/u24s2(orphan-recovery)、w22s3(web-blogfeed)、以及 u22s3/u24s3/w22s4 内的 plugin-fork case;仍红——engine-proofs full-mode restart wire ×4(u22s3/u24s3/w22s4)+ golden-storage-render ×4(w22s1,被 #4571 engineLane 戳顶掉)+ 可能还有 w22s1 的 #1365 Windows flake。前两条已带精确签名移交 #4599(含根因定位:engineLane 落盘字段晚于 re-pin;wire 腿 body #13 漂移超引用重编号范围待 triage),哨兵在 ci-fixes 扩展 re-pin 后,本分支再合一次新 tip 即全绿,无需再动本 PR 代码。按 2026-10-24 政策不为 CI 问题开新 issue(一律收敛 #4599),也无设计分叉点、无需 decision request。 收工判定:PR 代码就绪可审可合;CI 红为继承性测试钉债务,已移交 #4599 等待收敛。 |
(ai: vllm-qwen/qwen3.8-27b) 结论摘要(auto-fix lane attempt 2/2,最终轮)根因定位并已修复:本轮(run 40208958221)5 个红 shard 既不是本 PR 代码的问题,也不是 master 的 born-red 集群——查实 master 自身已连续 3 个 run 全绿(bb7c249)。红的真正来源是 attempt 1 我把当时正确、但现已过期的 ci-fixes re-pin(18f5146,早于 #4571 engineLane 戳时代)合到了绿 master 之上:它那 9 个测试文件(goldens + harness)与 master 现行行为不匹配,且与 master 的版本构成跨分支语义交互(无文本冲突、语义互相打架)。修复:这 9 个测试文件对齐回 master 版本(commit a98751b,纯 八问:
诚实披露:部分套件(golden ×4、orphan 1 例)在本沙箱连纯 master 都复现不出绿色,属环境差异,权威判定以 CI 为准(§7.2);若重跑后仍有个别 case 红(如新增测试文件引起 shard 重分区的抖动、或 Windows 特有的 opencode-inline),对应测试文件在 master CI 均通过且分支已是 master+PR 最小 delta,分支侧无更多可修之处,届时直接看重跑日志即可。已在 #4599 请哨兵确认 ci-fixes 的 storage-lane 部分可否标记 superseded(已被 master 取代)。按政策不为 CI 问题开新 issue,也无设计分叉点、无需 decision request。 收工判定:分支已到「master + PR」最小 delta 形态,这是该 CI 问题能收敛到的最干净状态;等 CI 重跑裁决。 |
(ai: vllm-qwen/qwen3.8-27b) Verified the duplication claim against both PRs before acting:
One policy note: agents are not permitted to close issues or PRs here — closing authority rests solely with the owner (@ranxianglei). What I've done instead: tagged this PR State of this branch for whoever closes: my last two commits were only CI alignment (merge of master + restoring nine stale test pins to master's versions, head 八问(中文结论):
收工判定:核实与标注已完成,等 owner/有权限者执行关闭;agent 侧无更多动作。 |
|
@ranxianglei Owner action needed: this PR is the verified duplicate of #4681, which was opened earlier, is broader, and is approved. The authenticated contributor account has read-only access and cannot execute |
(ai: vllm-qwen/qwen3.8-27b) Noted — this is now an owner-only action item. For a one-click decision by @ranxianglei: close this PR in favor of #4681. Everything needed to judge it is already in-thread above (verified earlier/broader/same-issue evidence), and the labels now carry the state: Two notes for whichever side wins:
Per policy I cannot execute the close myself; stopping here once it's done (or if the owner decides differently, e.g. keep both open). 八问(中文结论):
收工判定:等待 owner 执行关闭(或另行拍板);agent 侧动作已完成。 |
What
On an Anthropic-format upstream that signs thinking blocks, a cut inside bili's own re-request round (round >= 2, after a proxy tool like
compresscommitted work) stranded the client with an unsigned thinking block + a terminal error. Round-2 thinking streamed live; thesignature_deltanever arrived (socket cut mid-block); and #2501 correctly barred the only re-fetch that could have healed it. The user lost the turn and paid for it twice.Real incident 2026-10-25 (proxy mode, ~120k ctx): round 1 compress receipt 1231 chars; round 2 streamed 11949 reasoning chars over 94.9s then the socket died mid-body -> client assistant message = text(1231) + thinking(11949) with an empty
thinkingSignature.Root cause
In rounds > 1 the adapter held only the thinking start frame off the wire (#2501) but forwarded every payload delta live. A pre-signature cut left an open unsigned block the client could not replay -- round 1 committed visible text, and the round-2 request is bili's own, not the client's, so the client has nothing to resend. #2501's bar is correct for round 1 (the client owns that turn) but makes round >= 2 unrecoverable.
Fix
Hand the loop's signing evidence into
parseStream:ParseStreamOpts.upstreamSignsThinking, set inrunCompressLooptoctx.protocol === "anthropic" && (historyHasSignedThinking || sawSignedThinkingThisTurn).#2501's gate and all round-1 behavior are untouched. With no signing evidence the relay streams thinking live exactly as before -- no latency regression on unsigned relay lanes.
Behavior change (flagged per policy)
Residual hole (honest)
If the current request has no signed history and no earlier round of this turn produced a signature, there is no evidence yet -- that one round still streams live (pre-fix behavior). Detecting signing without evidence would require holding every relay's thinking to block end (a latency regression on unsigned GLM/DeepSeek-style relays), so evidence-based arming is the chosen tradeoff.
Config surface
None. No new config fields, env vars, or CLI flags.
Tests
tests/anthropic-round2-thinking-hold.test.ts:compress; attempt 1 cut mid-thinking, attempt 2 signed -> recovers. Fails on master (one fetch +event:error+ unsigned block on the wire).Targeted suites green (52 tests): this file plus
anthropic-truncation-unsigned-thinking(#2501),anthropic-thinking-replay,issue1960-thinking-verbatim,issue2407-thinking-caliber,issue1320-thinking-mass,loop-compress,anthropic-round2-stream,issue2499-anthropic-round2-cache,verif-wire-anthropic-roundtrip. Full-suite verdict = remote CI on this head.Closes #4679