Repository navigation
Conversation
Gemini v1internal API rejects requests that mix built-in tools (google_search) with functionDeclarations, returning 400 INVALID_ARGUMENT. Strip google_search/web_search/search_web from functionDeclarations before sending to Antigravity in both Gemini and Claude paths. toolConfig is only added when custom functionDeclarations remain. Ref: lbjlaq/Antigravity-Manager#2331, PR#2356
There was a problem hiding this comment.
Pull request overview
Updates the Antigravity (v1internal) request wrapper logic to avoid 400 INVALID_ARGUMENT by removing built-in search tools from functionDeclarations before forwarding requests, ensuring Antigravity only receives valid custom tool declarations.
Changes:
- Strip
google_search/web_search/search_web-style tools out offunctionDeclarationsfor the Gemini CLI → Antigravity envelope path. - Skip built-in search tools when converting Claude tools into Gemini
functionDeclarations, and only attachtoolConfigwhen custom tools remain.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+415
to
418
| if (GEMINI_BUILTIN_TOOLS.has(tool.name)) continue; // v1internal rejects mixing built-in with functionDeclarations | ||
| const cleanedSchema = cleanJSONSchemaForAntigravity(tool.input_schema); | ||
| functionDeclarations.push({ | ||
| name: sanitizeGeminiFunctionName(tool.name), |
Comment on lines
+306
to
315
| // Strip built-in tools (google_search etc.) — v1internal rejects mixing them with functionDeclarations | ||
| if (envelope.request.tools?.length > 0) { | ||
| const GEMINI_BUILTIN_TOOLS = new Set(["google_search", "web_search", "search_web", "googleSearch"]); | ||
| const allDecls = envelope.request.tools.flatMap(t => t.functionDeclarations || []); | ||
| const customDecls = allDecls.filter(fn => !GEMINI_BUILTIN_TOOLS.has(fn.name)); | ||
| envelope.request.tools = customDecls.length > 0 ? [{ functionDeclarations: customDecls }] : undefined; | ||
| } | ||
| const hasCustomTools = envelope.request.tools?.some(t => t.functionDeclarations?.length > 0); | ||
| if (hasCustomTools) { | ||
| envelope.request.toolConfig = { |
diegosouzapw
pushed a commit
to cheaper-inference/OmniRoute
that referenced
this pull request
Jun 26, 2026
…nt in Antigravity envelope
Antigravity's Cloud Code v1internal endpoint returns 400 when a Gemini
built-in tool (google_search / web_search / search_web / googleSearch) is
sent in the same request as custom functionDeclarations. wrapInCloudCodeEnvelope
now filters those built-in names out of the envelope's functionDeclarations,
drops a declarations entry that becomes empty, and only forces the VALIDATED
functionCallingConfig when custom declarations remain. Native grounding
entries (`{ googleSearch: {} }`) are preserved untouched.
Co-authored-by: Vanszs <vanszs@users.noreply.github.com>
Inspired-by: decolua/9router#1095
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.
Problem
Antigravity
v1internalAPI (cloudcode-pa.googleapis.com) rejects requests that mix built-in tools (google_search) withfunctionDeclarations, returning400 INVALID_ARGUMENT:{"error": {"code": 400, "message": "Request contains an invalid argument.", "status": "INVALID_ARGUMENT"}}This affects all clients (OpenClaw, Claude Code, Cline, etc.) that send
google_searchas a function tool alongside other tools — which is the default behavior for many AI agent frameworks.Root Cause
When a client sends
google_searchas a function tool in thetoolsarray, 9router forwards it as afunctionDeclarationsentry to Antigravity. Thev1internalprotocol does not supporttool_config.include_server_side_tool_invocations, so any mix of built-in tools and custom function declarations is rejected.Reference: lbjlaq/Antigravity-Manager#2331, PR#2356
Fix
Strip
google_search,web_search,search_webfromfunctionDeclarationsbefore sending to Antigravity in both paths:wrapInCloudCodeEnvelope(Gemini model path)wrapInCloudCodeEnvelopeForClaude(Claude model path)toolConfigis only added when customfunctionDeclarationsremain after stripping.Behavior
google_search+ custom tools:google_searchis stripped, custom tools forwarded normally ✅google_search: tools removed entirely, plain chat request ✅