Skip to content

fix(antigravity): allow cloudcode envelope through messages guard - #7582

Merged
diegosouzapw merged 3 commits into
diegosouzapw:release/v3.8.49from
dongwook-chan:fix/antigravity-cloudcode-envelope-guard
Jul 19, 2026
Merged

diegosouzapw merged 3 commits into
diegosouzapw:release/v3.8.49from
dongwook-chan:fix/antigravity-cloudcode-envelope-guard

Conversation

@dongwook-chan

Copy link
Copy Markdown
Contributor

Summary

Closes #7581.

This fixes two Antigravity MITM routing problems:

  • /v1/antigravity cloudcode envelopes no longer get rejected by the OpenAI top-level messages guard. Antigravity requests carry turns under request.contents, so missing top-level messages is valid for this endpoint.
  • Standalone MITM routing now prefers the client-facing mitmRouteAlias.antigravity namespace and only falls back to mitmAlias.antigravity, keeping MITM model routing separate from executor upstream-id cleanup while preserving compatibility.

Verification

Ran targeted regression tests:

node --import tsx/esm --test tests/unit/chat-messages-validation-6402.test.ts tests/unit/mitm-server-antigravity-route-alias.test.ts tests/unit/antigravity-format-detection.test.ts tests/unit/antigravity-mitm-model-resolution.test.ts

Result: 31/31 tests passed.

The Antigravity cloudcode regression loop covers the Gemini-family model set derived from ANTIGRAVITY_PUBLIC_MODELS, AGY_PUBLIC_MODELS, and ANTIGRAVITY_MODEL_ALIASES/values. It currently verifies 21 model IDs, including gemini-3.5-flash-low, gemini-3.5-flash-medium, gemini-3.5-flash-high, gemini-3.1-pro-high, gemini-3.1-pro-low, gemini-pro-agent, and rev19-uic3-1p, and asserts they route through the Antigravity executor without returning the missing-messages 400.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for the mitmRouteAlias namespace in src/mitm/server.cjs to separate client-facing OmniRoute model IDs from mitmAlias, prioritizing it during model mapping. Additionally, it updates src/sse/handlers/chat.ts to identify Antigravity requests by path and bypass the early validation guard requiring messages or input fields, as Antigravity requests utilize a cloudcode request envelope. Corresponding unit tests have been added to validate the routing behavior and the alias resolution order. No review comments were provided, so there is no feedback to address.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@diegosouzapw

Copy link
Copy Markdown
Owner

Thanks for tracking down the cloudcode-envelope guard bug — the chat.ts fix (bypassing the OpenAI messages requirement for /v1/antigravity) is correct and well-tested; I verified it applies cleanly to the current release/v3.8.49 tip and passes 26/26 in isolation.

The src/mitm/server.cjs half has drifted, though: getMappedModel() was renamed to getMappedOverride() on the release tip as part of the Antigravity reasoning-effort override feature (returns {model, reasoningEffort} via aliasConfigShim.normalizeAliasMappings(), not a plain string). Your getMappingFromSqlite/getMappingFromJson split needs to be re-applied on top of that shape rather than the old one — could you rebase onto release/v3.8.49 and reconcile there? Happy to help if useful. Also worth noting mitmRouteAlias isn't written anywhere yet in the codebase, so that half is prep for a future writer, not an active behavior change today — that's fine, just flagging so it's not mistaken for a live fix.

@dongwook-chan

dongwook-chan commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased onto the current release/v3.8.49 tip and reconciled the MITM alias lookup with the newer normalized override shape. Follow-up update: I also replaced the source-regex alias regression with behavior tests against the extracted route-alias resolver.

  • Kept getMappedOverride() returning { model?, reasoningEffort? } via aliasConfigShim.normalizeAliasMappings().
  • Added mitmRouteAlias as the first lookup namespace, with mitmAlias as the compatibility fallback.
  • Preserved applyAntigravityOverride() and reasoning-effort propagation through intercept().
  • Extracted route-alias resolution into src/mitm/_internal/routeAlias.cjs so SQLite and legacy JSON behavior are tested directly instead of asserted via source regex.
  • Confirmed mitmRouteAlias is currently preparatory because there is no writer yet.

Validation:

node --check src/mitm/server.cjs
node --check src/mitm/_internal/routeAlias.cjs
node --import tsx/esm --test tests/unit/mitm-server-antigravity-route-alias.test.ts tests/unit/mitm-alias-config-shim.test.ts tests/unit/mitm-antigravity-reasoning-effort-override.test.ts tests/unit/chat-messages-validation-6402.test.ts

Result: 50/50 tests passed.
git diff --check passed.

Current PR state: mergeable, Semgrep passed.

@dongwook-chan
dongwook-chan force-pushed the fix/antigravity-cloudcode-envelope-guard branch from 7c16f71 to aa39a6f Compare July 18, 2026 05:22
@dongwook-chan
dongwook-chan force-pushed the fix/antigravity-cloudcode-envelope-guard branch from 5a5c413 to c57e07a Compare July 18, 2026 09:22
dongwook-chan and others added 2 commits July 18, 2026 08:53
…under cap

resolveChatSourceFormatForPath() in chat.ts duplicated the exact
antigravity-path regex already in detectFormatFromEndpoint()
(open-sse/services/provider.ts) — the added function pushed chat.ts to
1808 lines, over the frozen file-size cap of 1797, with no baseline bump.

Remove the duplicate: add a thin detectFormatFromUrl(body, requestUrl)
wrapper next to detectFormatFromEndpoint (single source of truth for the
path/body-based format detection), and have chat.ts call it directly.
Also drop the now-single-use FORMATS import (compare against the literal
"antigravity", matching the existing convention in chatHelpers.ts) and
remove an unneeded block-scope around the pre-existing diegosouzapw#6402 messages
guard (renamed its local to msgBody — a second, separate `const b` block
further down for temperature/top_p/max_tokens/n validation is untouched
and does not collide).

Net effect: chat.ts 1808 -> 1797 lines (exactly at the frozen cap, no
baseline change). Behavior is unchanged — same tests, same guard logic,
same antigravity bypass. Re-verified full green: typecheck:core, eslint,
file-size/complexity/cognitive-complexity/complexity-ratchets/changelog-
integrity/test-discovery gates, and the PR's own regression suites
(chat-messages-validation-6402.test.ts 26/26, mitm-server-antigravity-
route-alias.test.ts 4/4), plus the adjacent format-detection and
chat-pipeline test suites.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
…guard

Resolve conflict in src/mitm/server.cjs: release's standaloneRouting.cjs
(multi-agent alias resolution, merged via diegosouzapw#7408's cycle) supersedes this
PR's mitmRouteAlias-only routeAlias.cjs, so drop the latter and its
now-orphaned unit test in favor of the release-side module.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
@diegosouzapw
diegosouzapw merged commit 9fce7d0 into diegosouzapw:release/v3.8.49 Jul 19, 2026
4 of 5 checks passed
@diegosouzapw

Copy link
Copy Markdown
Owner

Merged into release/v3.8.49 — thank you for the contribution, @dongwook-chan! 🎉 Validated in the final R3 merge-train (full static gates + unit suite on a dedicated 32-core box) before landing.

@diegosouzapw diegosouzapw mentioned this pull request Jul 23, 2026
HouMinXi pushed a commit to HouMinXi/OmniRoute that referenced this pull request Aug 2, 2026
…egosouzapw#7582)

* fix(antigravity): allow cloudcode envelope through guard

* fix(sse): dedupe antigravity source-format detection, shrink chat.ts under cap

resolveChatSourceFormatForPath() in chat.ts duplicated the exact
antigravity-path regex already in detectFormatFromEndpoint()
(open-sse/services/provider.ts) — the added function pushed chat.ts to
1808 lines, over the frozen file-size cap of 1797, with no baseline bump.

Remove the duplicate: add a thin detectFormatFromUrl(body, requestUrl)
wrapper next to detectFormatFromEndpoint (single source of truth for the
path/body-based format detection), and have chat.ts call it directly.
Also drop the now-single-use FORMATS import (compare against the literal
"antigravity", matching the existing convention in chatHelpers.ts) and
remove an unneeded block-scope around the pre-existing diegosouzapw#6402 messages
guard (renamed its local to msgBody — a second, separate `const b` block
further down for temperature/top_p/max_tokens/n validation is untouched
and does not collide).

Net effect: chat.ts 1808 -> 1797 lines (exactly at the frozen cap, no
baseline change). Behavior is unchanged — same tests, same guard logic,
same antigravity bypass. Re-verified full green: typecheck:core, eslint,
file-size/complexity/cognitive-complexity/complexity-ratchets/changelog-
integrity/test-discovery gates, and the PR's own regression suites
(chat-messages-validation-6402.test.ts 26/26, mitm-server-antigravity-
route-alias.test.ts 4/4), plus the adjacent format-detection and
chat-pipeline test suites.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

---------

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…egosouzapw#7582)

* fix(antigravity): allow cloudcode envelope through guard

* fix(sse): dedupe antigravity source-format detection, shrink chat.ts under cap

resolveChatSourceFormatForPath() in chat.ts duplicated the exact
antigravity-path regex already in detectFormatFromEndpoint()
(open-sse/services/provider.ts) — the added function pushed chat.ts to
1808 lines, over the frozen file-size cap of 1797, with no baseline bump.

Remove the duplicate: add a thin detectFormatFromUrl(body, requestUrl)
wrapper next to detectFormatFromEndpoint (single source of truth for the
path/body-based format detection), and have chat.ts call it directly.
Also drop the now-single-use FORMATS import (compare against the literal
"antigravity", matching the existing convention in chatHelpers.ts) and
remove an unneeded block-scope around the pre-existing diegosouzapw#6402 messages
guard (renamed its local to msgBody — a second, separate `const b` block
further down for temperature/top_p/max_tokens/n validation is untouched
and does not collide).

Net effect: chat.ts 1808 -> 1797 lines (exactly at the frozen cap, no
baseline change). Behavior is unchanged — same tests, same guard logic,
same antigravity bypass. Re-verified full green: typecheck:core, eslint,
file-size/complexity/cognitive-complexity/complexity-ratchets/changelog-
integrity/test-discovery gates, and the PR's own regression suites
(chat-messages-validation-6402.test.ts 26/26, mitm-server-antigravity-
route-alias.test.ts 4/4), plus the adjacent format-detection and
chat-pipeline test suites.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

---------

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(api): Antigravity MITM cloudcode requests are rejected by OpenAI messages guard

2 participants