fix(antigravity): strip trailing model turn for native Gemini requests too - #10436
Open
diegosouzapw wants to merge 1 commit into
Open
fix(antigravity): strip trailing model turn for native Gemini requests too#10436diegosouzapw wants to merge 1 commit into
diegosouzapw wants to merge 1 commit into
Conversation
…s too Newer Gemini endpoints reject a request ending on a model turn with HTTP 400 'Requests ending with a model turn are not supported' — the same rejection class Claude hits via Vertex. transformRequest() previously wired stripTrailingAntigravityAssistantTurn() only into the isClaude branch, so native Gemini models routed through Antigravity kept a trailing role:model entry and hit the 400. Extend the guarded strip (never empties contents) to native Gemini models too, gated by upstreamModel including "gemini". The Claude path is untouched (byte-identical), preserving PR #6114's live validation against Vertex Claude. Flips tests/unit/antigravity-claude-prefill-strip.test.ts test (b), which previously asserted the buggy pass-through, and adds (b2) for the gemini-3-flash-agent tier. Closes #10104
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 #10104
Root cause
AntigravityExecutor.transformRequest()inopen-sse/executors/antigravity.tsonlywired
stripTrailingAntigravityAssistantTurn()into theisClaudebranch. A nativeGemini model routed through Antigravity (
agy/gemini-*, e.g.gemini-3-flash-agent)that ends the conversation on a
role: "model"turn keeps that trailing entryunchanged, and newer Gemini endpoints reject that shape with HTTP 400 "Requests
ending with a model turn are not supported."
stripTrailingAntigravityAssistantTurn(already correct, guarded pop-loop, neverempties
contents) is now also applied on anisGeminibranch(
upstreamModel.toLowerCase().includes("gemini")), independent of thesanitizeAntigravityGeminiRequest()Claude-only field whitelist. The Claude path isbyte-identical to before — this only widens the strip to native Gemini requests.
Regression test
tests/unit/antigravity-claude-prefill-strip.test.ts:(
antigravity/gemini-3.1-pro) — flipped to assert the fixed behavior (trailingmodel turn stripped, contents ends on
user).gemini-3-flash-agenttier from PR refactor(antigravity): align official clients and callable catalog #8013'scatalog.
Fail→pass evidence (same test file, run against pre-fix vs post-fix
antigravity.ts):Gates run
npm run typecheck:core— cleannpx eslint --suppressions-location config/quality/eslint-suppressions.json open-sse/executors/antigravity.ts tests/unit/antigravity-claude-prefill-strip.test.ts— cleannode scripts/check/check-file-size.mjs— no new violations on touched filesnode scripts/check/check-test-discovery.mjs— OK, test file discoverednode --import tsx/esm --test tests/unit/antigravity-claude-prefill-strip.test.ts— 7/7 passnode scripts/check/check-complexity.mjs,check-cognitive-complexity.mjs, and the fullnpm run test:unitwere kicked off but did not finish within this session due to extreme host contention (13 parallel worktree sessions running the same checks concurrently, load average ~209). No failures observed in the partial output before the session ended; the change is a small, additive conditional branch unlikely to move complexity/cognitive thresholds. Recommend a follow-up CI run confirms these before merge.Notes
not performed — no reachable live Antigravity connection in this session. The TDD
fail→pass proof above is the validation path per the plan file's own fallback.
isClaudebranch, PR fix(antigravity): strip trailing assistant prefill for Vertex Claude models — relocated to live executor, NEEDS LIVE VALIDATION #6114) is untouched — byte-identical.