Repository navigation
fix: normalize Google user-side part order for Vertex — plain text before functionResponse (#3159) - #3167
Merged
Conversation
Contributor
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3708-pr.3167.005cd70This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3167.tgz
npm install -g packageInstall instructions are refreshed on each push. |
Owner
Author
(ai: vllm-qwen/qwen3.8-27b) 独立 review 完成。结论:方向正确、机制健全,但初版 head 有两处遗漏——已在 PR 分支上顺手补齐,当前 head 结构化八问
Review 发现(独立审核产出,已顺手修掉)
行为变更披露(old → new)混合 Google user content(纯文本跟在 functionResponse 后)现在以 判定: |
added 8 commits
October 14, 2026 21:12
… functionResponse (#3159) Vertex rejects a request whose user content carries plain (unsigned, non-thought) text AFTER a functionResponse part with 400 'Requests ending with a model turn are not supported' (controlled A/B matrix in #3159; Gemini Developer API accepts both orders). coreToGoogle's flushUser reassembled every user run as [responses..., content...], so even a client sending the safe [text, functionResponse] order was forwarded defective. Add normalizeGoogleUserPartOrder (stable partition; signed/thought/non-text parts never move; byte-stable no-op when no plain text follows a functionResponse) and apply it in flushUser. Bump acp-kernel to 0.0.124.
…ailing content (#3159) appendGoogleNudge appended any trailing note or nudge text AFTER the existing parts of the last user content — after a tool response that produced the same Vertex 400 shape the kernel rebuild fixed (the note was added post-rebuild, so the kernel fix alone could not cover it). Wrap the appended parts in the kernel's normalizeGoogleUserPartOrder so the new text leads; all append callers (nudge, system-anchor notes, image notes) share this one boundary.
Add WC-017 to the wire-contract ledger (Vertex rejects plain unsigned non-thought text after a functionResponse part in user content; provenance: #3159 production 400 + controlled A/B matrix), enforced in the validation-parity fake on every forwarded Google body plus a unit gate and ledger self-check probe. New e2e regression drives both producers through the real proxy against the enforcing fake: a system-anchor drift note appended after a tool response, and a client's own defective [functionResponse, text] order — both must forward with text first or the fake relays its 400.
…lugin matrix The google lane now forwards user contents ending on tool results with new plain-text parts LEADING (Vertex rejects text after functionResponse, #3159). Between a fold turn and the next, the previous body's trailing tool units therefore shift right past an inserted run of text units from the same content — assertPrefix gains a scoped allowCanonShift that sanctions exactly that move (google lane, two call sites); every other comparison stays an exact byte-prefix.
The golden scenario drives tool pairs on every even turn, so each merged user run [fr, next-text] hits exactly the shape Vertex rejects and the normalizer now re-lays out. Outbound body digests from turn 1 onward and the fold-reconciliation canon snapshot (metadata.foldPositions) reflect the new layout; state/blockContents/stats sections are unchanged. Only google.json drifts — chat/anthropic/responses regenerate byte-identical.
…aries (#3159) Two more producers of the WC-017 shape survived the rebuild-level fix: appendTrailingUserText (degenerate-turn retry nudge — enabled by default, and the opt-in fake-completion hint) merges its text into the last user content's parts AFTER the body is assembled, and insertCheckpointCarrier (opt-in outbound chain stamp, relay egress) appends the carrier tag the same way. Both landed plain text after a trailing functionResponse part — exactly what Vertex rejects — invisible to the kernel rebuild and to appendGoogleNudge. Both boundaries now consume the exported normalizeGoogleUserPartOrder; safe shapes stay byte-identical. Regression gates added to the #3159 suite: exact order assertions plus a WC-017 ledger-validator check on each mutated body, and a no-defect byte-stable control.
…3159) Master moved the google golden's stateDigest/metadata section digests since our base (post-base state-level changes); re-running the generator on the rebased tree folds master's baseline in under the #3159 part-order re-layout. Turn body shas unchanged by this step; other wires byte-identical.
ranxianglei
force-pushed
the
2026-10-14_fix-3159-vertex-nudge-order
branch
from
October 14, 2026 13:20
9df9817 to
5fc68be
Compare
Contributor
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.436-master.e7e7c39 # this exact build
npm install -g billion-context@master # always the newest merged build
|
This was referenced Oct 16, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3159
kernel-change: Vertex rejects user content carrying plain text after a functionResponse part (400 "Requests ending with a model turn are not supported"), and coreToGoogle's flushUser reassembled every user run as [responses..., content...] regardless of the client's own order — the ordering guarantee cannot be expressed host-side, so the fix lives in the wire rebuild. Host append boundaries add text post-rebuild, so they consume the new exported helper normalizeGoogleUserPartOrder from acp-kernel/wire rather than duplicating the predicate.
What
Vertex A/B matrix from #3159: final user parts [functionResponse] -> 200; [functionResponse, text] -> 400; [text, functionResponse] -> 200 (Gemini Developer API accepts both orders — Vertex-specific strictness). Bili produced the defective shape at four boundaries:
coreToGoogle's flushUser rebuilt every merged user run as[...responses, ...content], so even a client sending the safe order was forwarded defective. NewnormalizeGoogleUserPartOrder(parts)stable-partitions unsigned, non-thought plain text before non-text parts when plain text follows a functionResponse part; applied in flushUser. Signed (thoughtSignature) / thought / non-text parts never move; nothing is dropped or rewritten; shapes without the defect come back byte-identical (the prefix-cache anchor is untouched).appendGoogleNudgeappended nudge/note text AFTER the existing parts post-rebuild (invisible to the kernel fix). It now wraps the appended parts in the same normalizer, covering all append callers: nudge, system-anchor drift notes, image notes.appendTrailingUserText(degenerate-retry nudge, fake-completion hint) built the same post-assembly shape; now normalized at the shared boundary.insertCheckpointCarrier(opt-in outbound chain stamping) likewise; now normalized at the shared boundary.Wire-contract ledger (#1304)
WC-018 added (wire: google) with provenance (#3159 production 400 on dsh-vertex-argon 1.1.4 / DSH 0.2.0-rc.2 over billion-context 0.1.196, official Vertex endpoint, gemini-4-argon generateContent; controlled A/B matrix 2026-10-14), enforced in the validation-parity fake on every forwarded Google body, plus a unit gate and a ledger self-check probe. (Landed as WC-017 on the feature branch; master's #3072 took that id first for the codex lane, so the rule renumbers to WC-018 on rebase.)
Tests
allowCanonShiftin assertPrefix (google lane only, two call sites) — the P1 byte-prefix pin ([test] Plugin-mode cache-friendliness invariants — same matrix as #1548's proxy-mode suite, as a permanent gate #1553/plugin mode: in-place acp_summary never stripped when the client's own compress pair rides inbound — double summary carrier on every post-fold turn #1567) now sanctions exactly one canonical move: after a fold turn, the new plain text leads the fold-pair's functionResponse, shifting the pair result right past it. Every other wire and turn stays strict byte-prefix.Rebase / integration note
Rebased onto master bd2aa6e, which includes #3171 (fix(pi): tolerate undefined ctx in tool-guardrails event handlers, #3170 ①) and its test follow-ups (#3170 ② XDG lock fixture) — master's own test defects that had been red-ing this PR's shard-2/shard-3 legs via merge-ref checkout before the rebase. Also integrates two sibling-session commits fixing the remaining two post-assembly boundaries (items 3–4 above).
Behavior change (old -> new)
A mixed Google user content carrying plain text after a functionResponse part is now forwarded with the plain-text parts BEFORE the non-text parts — a one-time wire-byte reorder per affected request ([fr..., text...] -> [text..., fr...]). Pure/safe shapes are byte-identical (the normalizer is a no-op without the defect). This changes what Vertex receives for exactly the requests that currently 400; nothing else moves. One bounded prefix-cache invalidation at those turns (documented by the cfp suite amendment).
Config surface
None. No config field added, renamed, or re-semantics'd; no new env var or flag.
Out of scope: #3158 (response-side signature loss found during the same investigation) is tracked separately.