Repository navigation
[PR] fix: preserve signed ordinary text parts on the wire and in tool-loop rebuilds - #6859
ranxianglei wants to merge 1 commit into
Conversation
… rebuilds (#6842) Gemini can attach a thoughtSignature to an ORDINARY text part (without thought: true). The signature is verified byte-for-byte over the part's text on replay (KDD #10), so such a part must be treated like a thought part — never rewritten. Before: the Google SSE adapter and the non-streaming JSON rewriter only exempted thought: true parts from prose filtering, so a signed ordinary text part containing marker-like text was mutated before reaching the client. Separately, the streaming tool loop recorded ordinary text as a merged string and dropped its signature when rebuilding the next upstream request, even when the text contained no markers. Now: signed ordinary text parts are never prose-filtered (adapter + JSON rewriter), keeping the text, signature, and part boundary byte-exact on the client wire. The loop carries the signature on the text part and puts it back on the re-request (googleThoughtSignature) at its position, so the continuation agrees with the client's persisted history. A signed text part is a complete part: Gemini computes the signature over the full part text, so it arrives in the part's last chunk; any later text delta starts a new part. Closes #6842
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.10227-pr.6859.8f0947bThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr6859.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。检索 open+closed 的 issue 与 PR,与 #6842 相关的既有工作:#3162(standalone signature)、#6103(promote sig to surviving functionCall)、#6623(duplicate whole-frame forwarding)——三者都仍把 signed ordinary text 当 unsigned prose 处理,与本 PR 的修复面(把 signed ordinary text 从 prose filter 豁免 + 在 rebuild 里带回 signature)不重叠。本 thread 无并列的第二条 fix PR(#6859 是唯一)。 Review of #6859 — preserve signed ordinary text partsVerdict: MERGEABLE (pending CI green — 30 checks, 0 failed, 13 still running at review time). Direction (① 原 issue)#6842 reports that Gemini attaches
The PR fixes both root causes, not the symptom: it changes the filter-exemption condition from "is thought" to "is thought OR carries a non-empty Regression audit (② 既有行为清点)The diff touches 4 files (+389/−8), all on-topic, no unrelated churn. Branch is fresh (0 behind master @
No semantic drift, no fail-fast→swallow, no threshold/timing/output-format drift. No kernel/ changes — the kernel already maps Test validity (④)
Loop-level byte-equality on the re-request body (f/g/h) + client-visible stream (a/b/c) — satisfies KDD#10's requirement for both signed wires. Local targeted verification (on PR head
|
🔶 需要决策 The #6859 ↔ master conflict is not a textual merge conflict — it is two competing fixes for the same issue (#6842) colliding on three files. Resolving it means choosing/combining implementations, which is a design call I will not make unilaterally. I did NOT force-push and did NOT touch any branch. What I verified (evidence, not guessing)
The key finding (I ran the tests)I ran the PR's own test file
Bottom line: the PR is not redundant — its test catches a real (edge-condition) defect in the already-merged Afloat fix. But Afloat's fix has wider coverage (full-part preservation via 八问(决策请求)
选项对比
Recommendation: C/D — keep Afloat's wider coverage (full part + Default if undecided: leave the PR conflicted (no force-push), keep master on Afloat's fix as-is (zero new regression), and let the multi-chunk gap stay documented here for a follow-up PR once the direction is set. (Closing the PR is owner-only; I will not close it.)
|
[ework] CI fix verified green ✓ |
Status (re-trigger, floor 9): unchanged since floor 6 — still waiting on your A/B/C/D call. No force-push, no branch touched. Re-verified live this run (not from memory):
Per my stated default (floor 6): holding — no force-push, master stays on Afloat's fix (zero new regression). The full analysis (options table, the I need your call on A/B/C/D to proceed. Until then, each re-trigger will find the same state. (Closing the PR is owner-only; I will not close it.) 八问(状态更新,细节见 floor 6)
|
[ework] CI fix verified green ✓ |
2 similar comments
[ework] CI fix verified green ✓ |
[ework] CI fix verified green ✓ |
(ai: vllm-qwen/qwen3.8-27b) Status (3rd re-trigger, floor 15): still unchanged — owner decision on A/B/C/D still pending. No force-push, no branch touched. Re-verified live this run:
This is the 3rd re-trigger with no decision yet. The full analysis (options, the To stop the re-trigger loop, please either:
八问(状态更新,细节见 floor 6)
|
[ework] CI fix verified green ✓ |
(ai: vllm-qwen/qwen3.8-27b) Status (4th re-trigger, floor 19): still unchanged — owner decision on A/B/C/D still pending. No force-push, no branch touched. Re-verified live this run:
This is the 4th re-trigger with no decision. The full analysis (options, the To stop the re-trigger loop, please either:
八问(状态更新,细节见 floor 6)
|
[ework] CI fix verified green ✓ |
1 similar comment
[ework] CI fix verified green ✓ |
(ai: vllm-qwen/qwen3.8-27b) Status (5th re-trigger, floor 24): still unchanged — owner decision on A/B/C/D still pending. No force-push, no branch touched. Re-verified live this run:
This is the 5th re-trigger with no decision. The full analysis (options, the To stop the re-trigger loop, please either:
八问(状态更新,细节见 floor 6)
|
[ework] CI fix verified green ✓ |
(ai: vllm-qwen/qwen3.8-27b) Status (6th re-trigger, floor 28): still unchanged — owner decision on A/B/C/D still pending. No force-push, no branch touched. Re-verified live this run (not from memory):
This is the 6th re-trigger with no decision. The re-trigger loop will continue until either the owner decides or the PR is closed. The full analysis (options table, the To stop the re-trigger loop, please either:
八问(状态更新,细节见 floor 6)
|
[ework] CI fix verified green ✓ |
(ai: vllm-qwen/qwen3.8-27b) Status (7th re-trigger, floor 32): still unchanged — owner decision on A/B/C/D still pending. No force-push, no branch touched. Re-verified live this run (not from memory):
This is the 7th re-trigger with no decision. The full analysis (options table, the To stop the re-trigger loop, please either:
八问(状态更新,细节见 floor 6)
|
[ework] CI fix verified green ✓ |
(ai: vllm-qwen/qwen3.8-27b) Status (8th re-trigger, floor 36): still unchanged — owner decision on A/B/C/D still pending. No force-push, no branch touched. Re-verified live this run (not from memory):
This is the 8th re-trigger with no decision. The full analysis (options table, the To stop the re-trigger loop, please either:
八问(状态更新,细节见 floor 6)
|
[ework] CI fix verified green ✓ |
Closes #6842
What
Gemini can attach a
thoughtSignatureto an ordinarytextpart (nothought: true). Per KDD #10, a signed block is verified byte-for-byte on replay and must never be rewritten. Two paths violated that for signed ordinary text:thought: trueparts from prose filtering, so a signed ordinary text part containing marker-like text (render tags /[ACP]markers / bili internal artifacts) was mutated before reaching the client.How
src/loop/adapter-google.ts: a text part carrying a non-emptythoughtSignatureis now treated like a thought part — never prose-filtered, and the signature rides the loop event. The complete frame was already forwarded verbatim via the carrier mechanism, so the client now gets the text + signature byte-exact (SSE and JSON-array forms).src/loop/core.ts: thetextRoundPart/ParsedStreamEventcarry an optionalsignature. Accumulation treats a part that already carries its signature as complete (Gemini computes the signature over the full part text, so it arrives in that part's last chunk; any later text delta starts a new part). The proxy-tool rebuild puts the signature back on the re-request asgoogleThoughtSignatureat the part's position, so two adjacent signed parts stay two signed parts with their boundary intact.src/stream-google.ts: the non-streaming JSON rewriter exempts signed parts fromstripAcpTags(and from therequestTextpre-scan).Behavior changes (old → new)
thoughtSignature→ now carriesgoogleThoughtSignature. (Unsigned text still gets no signature — nothing is fabricated.)Both changes are the intended fix for the reported corruption. Existing
thought/functionCall/ standalone-signature behavior is unchanged (gated by negative test rows).Modes
Reasoned in both compression modes. The client-wire fix is mode-independent (adapter + JSON rewriter run on every response). The re-request fix lives in the proxy-tool rebuild, which is exercised in proxy mode; the adapter's signature-carrying event is also what plugin mode's re-sent history relies on. The regression suite covers both SSE and non-streaming JSON responses.
Tests
New
tests/issue6842-google-signed-ordinary-text.test.ts(11 tests, both directions per gate discipline):thoughtparts + standalone signatures keep existing behaviorthought+ realfunctionCallunchangedTargeted suites green on the rebased head (71 tests incl. issue3158, json-rewrite-history, adapter-google, e2e-google-compress); typecheck + build clean. Full-suite verdict is the CI
testlanes.No new config surface. No wire-contract ledger entry — this establishes local wire corruption / metadata loss, not a new upstream rejection constraint (per the issue, no claim that every model rejects missing text-part signatures with HTTP 400).