Repository navigation
[PR] fix: Antigravity Gemini-4 1M context window + v1internal continuation-leg replay - #6969
ranxianglei wants to merge 8 commits into
Conversation
The probe anchor PROXY_TOOL_AT=6 was calibrated on 2026-10-31 for #4521 (schedule {4,6,8,9}). The nudge scheduling has shifted again — nudge now lands at {3,5,11,14}. Re-calibrate the anchor to the next nudge-carrying request pair (5 → tool round, 6 → fold round). The fold/proxy-tool-round mechanics under test are unchanged. Closes: master-red on test (windows-latest, 22, 3) and (ubuntu-latest, 22, 1).
…1M (#6963) gemini-4-{carbon,argon,hydrogen}-{low,medium,high,xhigh} and the role-suffixed CloudCode ids (gemini-pro-orchestrator(-argon), gemini-pro-agent, gemini-flash-worker-agy, gemini-pro-latest, gemini-flash-latest, gemini-flash-lite-latest) matched no CONTEXT_LIMIT_TABLE entry and fell to the anonymous 200K default: preflight 502 at ~227K input and clampOutgoingOutput clamping 262144 -> 4096 at ~168K. A too-large guess self-heals on the first upstream overflow (#852); a too-small one strands the session (#282).
… legs (#6963) A v1internal continuation leg (continuationToken present) re-ran the full stateful pipeline — nudge / status line / ACP tag re-render / output clamp — mutating the outbound body vs the minting leg. Upstream binds the token to the exact bytes it saw on that leg and 400s any deviation ('does not match the continuation token'). Every v1 egress now records its inner on the session (in-memory transient, latest-wins, countTokens egress excluded — it never mints continuation tokens). A continuation leg replays the cached inner byte-identical, splicing back only the client's fresh maxOutputTokens (accumulated across legs — upstream tells the client to pass a higher value) and the token itself, at whichever of meta / inner root / generationConfig (camelCase or snake_case) it arrived in; a stale token from a previous leg is stripped from every location first. The pipeline is skipped entirely; the relay re-wraps with the incoming leg's own envelope meta. Cache miss (restart / orphan token) falls through to the full pipeline — pre-fix behavior, with a warn log.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.10482-pr.6969.ea6ff1eThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr6969.tgz
npm install -g packageInstall instructions are refreshed on each push. |
The probe's hardcoded request-index anchors (PROXY_TOOL_AT/FOLD_AT) broke every time the nudge gate's schedule shifted. The last recalibration (245ecb1) was measured on a direct local run (timestamps ON by default since #4313), but CI runs the suite preload pin BILI_MESSAGE_TIMESTAMPS="0" (timestamps OFF) — a different wire shape, a different schedule (no nudge at index 5) — so it passed locally and failed on every CI shard. Root-cause fix instead of another anchor whack-a-mole: - Arm the fold on the first request carrying the ephemeral nudge with >=11 tagged refs; fold on the re-request after the acp_status round. The probe now materializes the #2929 scenario wherever the schedule places it. - Pin compress.messageTimestamps:false so the probe's wire shape is hermetic regardless of how the suite is launched (matches the CI preload pin). Supersedes the 245ecb1 recalibration. Verified: passes with and without the preload pin, same deterministic schedule (nudge at inputs[7], fold at inputs[8]).
The type is only referenced inside src/v1internal.ts itself; the gate flags it INTERNAL_ONLY. No dts surface is emitted (tsup config has no dts), so the non-exported type in the exported signatures is safe.
…4-window-continuation-replay
(ai: opencode/qwen3.8-27b) 查重: 不重复 — scanned open [PR] rows: no other open PR fixes #6963. Nearest neighbor #6967 (401 re-request on v1internal) is a different issue and a different mechanism (re-request auth, not continuation-token byte binding). Review of PR #6969 — head Direction (① original issue): matches. Issue #6963 = two interacting bugs: (1A) the Antigravity Gemini line ( Regression (②), verified against pre-change code, not just the diff:
Code (③): clean. Splice helper is pure, narrow, well-named; the gate is four explicit conditions; cached-body parse failure degrades to the full pipeline with a warn (no silent swallow). No dead code, no magic numbers, style matches the repo. Tests (④): hermetic helper tests pin precedence (meta > inner > generationConfig), both spellings, non-string/empty rejection, and splice semantics (token + budget only; contents/tools/sessionId preserved; no cross-location leak). 5 e2e lanes through the real proxy: byte-identical replay, orphan-token fallback, countTokens no-clobber, inner-root/meta token locations, enveloped SSE response. I reproduced the pre-fix failure myself: checking out the merge-base handle.ts makes Test A fail with Diff cleanliness (⑤): the PR-specific diff is tight — all 9 files relate to the fix. The three-dot diff also carries the #2929 test recalibration, which is the sanctioned Base freshness: the PR was 53 commits behind master; the author merged master + ci-fixes into the branch (1a4450b, bcd7251). PR hunks do not overlap master churn in the same files. Verified on the current head: Labels: CI: in progress on current head One PR-body inaccuracy (minor, no code change needed): the "Accepted boundary" section says a model-emitted compress tool call on a continuation leg "would enter the compress loop with empty 8问(结构化结论)
判定:APPROVE —— 无阻断项;CI 在 |
Closes #6963
What
Two interacting bugs broke Antigravity (CloudCode) long-output turns with HTTP 400:
gemini-4-*and the role-suffixed CloudCode ids (gemini-pro-orchestrator(-argon),gemini-pro-agent,gemini-flash-worker-agy,gemini-pro-latest,gemini-flash-latest,gemini-flash-lite-latest) matched noCONTEXT_LIMIT_TABLEentry → anonymous 200K default → preflight 502 at ~227K input andclampOutgoingOutputclamping 262144→4096 at ~168K (the issue'soutput budget clamped 262144 -> 4096 … window=200000log line).How
gemini-4*andgemini-(pro|flash)-(orchestrator|worker|agent|latest|lite)*to the table at 1_048_576 (before thegemini-3row). Table philosophy: a too-large guess self-heals on the first upstream overflow ([Question] deepseek-flash 被静态兜底表解析为 128k,真实窗口 1M —— 是有意设置,还是兜底表过期? #852); a too-small one strands the session (bili出现连续压缩情况 #282).session.transient.v1ContinuationReplay(in-memory only, latest-wins, countTokens egress excluded — it never mints continuation tokens). A continuation leg (token found at envelope meta / inner root /generationConfig, camelCase or snake_case) replays the cached inner byte-identical, splicing back only the client's freshmaxOutputTokens(accumulated across legs — upstream tells the client to pass a higher value) and the token itself; a stale token from a previous leg is stripped from every location first. The pipeline is skipped entirely; the relay re-wraps with the incoming leg's own envelope meta (fresh requestId). Cache miss (restart / orphan token) falls through to the full pipeline with a warn log — pre-fix behavior.Behavior changes
v1Meta !== undefined); non-continuation v1internal legs are untouched (no token → no replay).session.transient.v1ContinuationReplay— in-memory only, excluded from the persistence projection, ~1MB bounded by the session's own egress size.lookupContextLimitreturns 1_048_576 for the Antigravity Gemini line (was: 200K anonymous default). This moves the preflight wall and the output clamp for those models from ~200K to ~1M — intended; per-model route config still overrides.Tests
tests/issue6963-v1internal-continuation.test.ts(new): hermetic splice-helper tests + 5 e2e lanes through the real proxy (byte-identical replay, orphan-token fallback, countTokens no-clobber, inner-root/meta token locations, enveloped response). Test A fails on the pre-fix code with5948 !== 8192(the clamp mutating the leg) — verified by reverting the handle.ts hunk and re-running.tests/routing.test.ts: new row pinning the Antigravity line at 1M + controls for the pre-existing Gemini entries.Accepted boundary
A continuation leg whose model output emits a compress tool call would enter the compress loop with empty
processedMessages(the replay Prepared ships minimal message arrays — both empty, the same shape the countTokens lane's fallback path ships through the same relay). Pathological: the model is mid-prose on a continuation leg, and pre-fix that scenario 400'd before any response was read.