Repository navigation
fix: preserve standalone thoughtSignature parts in the Google loop adapter (#3158) - #3162
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3609-pr.3162.3b46741This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3162.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…ol rebuild (#3158) Review follow-up: a standalone thoughtSignature part sharing a frame with successfully forwarded text was client-visible through the whole-frame raw forward but never emitted as a standalone_signature event (the per-chunk block gated on !emitted), so a later proxy-tool rebuild dropped it from the re-request — the same lost-association class this PR fixes, narrower trigger. Decouple recording from forwarding; add test #3158 l pinning it.
(ai: vllm-qwen/qwen3.8-27b) 独立审核完成(不复述 PR 描述,以下结论均基于自己对 diff、周边代码与 kernel 源码的重新核查)。审核中发现一处完整性缺口,已按「小问题直接修」直接在 PR 分支补掉(commit 1. 是什么问题:Gemini 的推理签名 2. 什么原因导致的:adapter 的 part 建模缺口(源头层),不是下游过滤问题。kernel 侧我独立验证了 PR 的关键论断:入站(kernel/src/wire/google.ts step 3,sig-only part 通过 3. 影响范围与严重程度:触发条件 = Google lane + 流中出现签名-only part + 会话走 proxy-tool rebuild(即发生过 proxy-only 调用轮次)。后果是 wire 保真度问题(签名关联静默丢失),不是硬故障;特定条件下有问题,属数据完整性级。FunctionCall 附着签名不受影响(独立路径),PR 说明准确。 4. 怎么修复的:在源头(adapter)把 standalone 签名 part 纳入建模:per-chunk 逐字转发(无其他内容时整帧原样,否则只装这些 part 的 wrapper,早到 finishReason 剥离)+ settle 两分支各发 5. 是否有回归问题(逐项审过的既有行为):
6. 是否破坏缓存:不涉及。去重键、增量游标、prefix-cache 策略均未触碰;rebuild 新增的 core 只在该会话实际出现过 sig part 时才出现。 7. 是否改了设计方向:没有。kernel 零改动(已独立验证其 round-trip 能力),仅扩展 loop 的事件/round-part 词汇表一种类型。 8. 是否引入了新的配置:没有(config surface 零变更,PR 声明属实)。 披露的行为变更(重试门)我独立核实为真且正确:core.ts:832-844 的盲重取门要求 测试有效性:断言有牙——字节计数( CI 状态:旧 head 上 38 项检查恰有 1 项红: 热文件观察:在途 #3154(round 级熔断 → core.ts)、#3107(degenerate-turn 诊断 → adapter-google)、#2805(google lane ACP strip)、#2783(dsh novelty gate 双 lane)与本 PR 语义相邻,当前与 master 无文本冲突;若其中任一先合并,需 rebase 后再看。 判定:方向正确、根因在源头修、回归审计通过(含我自己补掉的同族缺口)、披露诚实。待新 head CI 全绿即可合并(合并留给人)。 |
(ai: vllm-qwen/qwen3.8-27b) 跟进 CI 结果:新 head 最终判定:CI 全绿,可合并。 审核结论维持上一条回复:根因在源头修复、回归审计通过(含我补掉的同帧 sig 完整性缺口)、披露的重试门行为变更核实为真且正确、无 kernel/配置面改动。合并留给人。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.434-master.805f12b # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #3158
Problem
Gemini streams sign reasoning blocks with
thoughtSignature. The signature can ride its OWN part with no text at all (a late association for an earlier block, or the whole block's signature when the text arrived unsigned). The Google loop adapter modeled onlytext/thought/functionCallparts, so a signature-only part fell through every branch and vanished from the client's wire; the loop's proxy-tool rebuild had no record of it either, so re-requests lost the association as well.Verified on master before the fix with the issue's exact four-frame repro: signature occurrences in forwarded bytes = 0.
Fix
src/loop/adapter-google.ts
finishReasonis stripped so the synthetic completion stays the sole terminal frame.prosePartsOf(the drop-path resynthesis after a proxy-only call chunk) now keeps nonempty-signature parts alongside prose, so a signature sibling of a dropped call chunk still reaches the client.standalone_signatureevent per such part so the loop records them in stream order.src/loop/core.ts
standalone_signature, recorded intoroundParts.acp_loop_r{round}_asst_sig[_N]) withgoogleThoughtSignature+rawGoogleParts:[{thoughtSignature}]at the part's stream position.rawGooglePartsis required:contentPartsreturns the raw verbatim only when the raw's texts equal the core's text, and an empty-text core without raw would serialize to zero parts — content vanishes.The kernel already round-trips this shape verbatim (inbound sig-only part → empty-text core +
rawGoogleParts; outbound returns raw verbatim), so no kernel change.Behavior change (disclosed)
A truncated Google round whose only output was a forwarded standalone-signature chunk previously qualified for the blind zero-side-effect refetch (#413 gate shape (a)). The forwarded chunk now sets
forwardedFraming, which bars that refetch on google (only openai/anthropic keep the framing exception). Such a turn now ends with the truncation surfaced through the completion instead of a silent re-fetch — correct, because the signature bytes were already client-visible and a re-fetch would duplicate them. Rare corner: requires truncation immediately after a late signature-only frame.Out of scope (unchanged): other opaque non-text parts (
inlineData/fileData/videoMetadata) are still not modeled by the streaming path — that family belongs to #2609/#2614. FunctionCall-attached signatures were never affected (separate handling path).Tests
New
tests/issue3158-google-standalone-signature.test.ts(10 cases): the issue's exact four-frame repro in SSE and JSON-array transport forms, empty-text-with-signature, mixed text+signature (no duplication), terminal-chunk shapes (no early finish leak), real-call sibling (verbatim replay), proxy-call sibling (drop-path resynthesis), loop-level re-request carrying the signature back (both the per-chunk and the settle path), and the retry-gate change pinned. Existingtests/adapter-google.test.tsandtests/issue1455-truncation-ping.test.tsgreen locally; full suite on CI.No config-surface change. No kernel change. No version bump.