Skip to content

Commit f6b480e

Browse files
committed
fix(rotator_library): šŸ› enforce parameters key for antigravity tool schemas
The Antigravity API backend expects the `parameters` key for tool definitions across all models. Previously, the provider used `parametersJsonSchema`, which caused `MALFORMED_FUNCTION_CALL` errors specifically with Gemini 3 Pro. - Update `AntigravityProvider` to exclusively use the `parameters` key when constructing requests. - Update schema enforcement and `GeminiToolHandler` to support reading/modifying schemas via either `parametersJsonSchema` or `parameters`. - Remove obsolete Claude-specific tool transformation logic.
1 parent 2da13f5 commit f6b480e

File tree

2 files changed

+26
-33
lines changed

2 files changed

+26
-33
lines changed

ā€Žsrc/rotator_library/providers/antigravity_provider.pyā€Ž

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,19 +2741,23 @@ def _enforce_strict_schema_on_tools(
27412741
Apply strict schema enforcement to all tools in a list.
27422742
27432743
Wraps the mixin's _enforce_strict_schema() method to operate on a list of tools,
2744-
applying 'additionalProperties: false' to each tool's parametersJsonSchema.
2744+
applying 'additionalProperties: false' to each tool's schema.
2745+
Supports both 'parametersJsonSchema' and 'parameters' keys.
27452746
"""
27462747
if not tools:
27472748
return tools
27482749

27492750
modified = copy.deepcopy(tools)
27502751
for tool in modified:
27512752
for func_decl in tool.get("functionDeclarations", []):
2752-
if "parametersJsonSchema" in func_decl:
2753-
# Delegate to mixin's singular _enforce_strict_schema method
2754-
func_decl["parametersJsonSchema"] = self._enforce_strict_schema(
2755-
func_decl["parametersJsonSchema"]
2756-
)
2753+
# Support both parametersJsonSchema and parameters keys
2754+
for schema_key in ("parametersJsonSchema", "parameters"):
2755+
if schema_key in func_decl:
2756+
# Delegate to mixin's singular _enforce_strict_schema method
2757+
func_decl[schema_key] = self._enforce_strict_schema(
2758+
func_decl[schema_key]
2759+
)
2760+
break # Only process one schema key per function
27572761

27582762
return modified
27592763

@@ -3240,12 +3244,20 @@ def _build_tools_payload(
32403244
32413245
For Gemini models, all tools are placed in a SINGLE functionDeclarations array.
32423246
This matches the format expected by Gemini CLI and prevents MALFORMED_FUNCTION_CALL errors.
3247+
3248+
Uses 'parameters' key for all models. The Antigravity API backend expects this format.
3249+
Schema cleaning is applied based on target model (Claude vs Gemini).
32433250
"""
32443251
if not tools:
32453252
return None
32463253

32473254
function_declarations = []
32483255

3256+
# Always use 'parameters' key - Antigravity API expects this for all models
3257+
# Previously used 'parametersJsonSchema' but this caused MALFORMED_FUNCTION_CALL
3258+
# errors with Gemini 3 Pro models. Using 'parameters' works for all backends.
3259+
schema_key = "parameters"
3260+
32493261
for tool in tools:
32503262
if tool.get("type") != "function":
32513263
continue
@@ -3285,11 +3297,11 @@ def _build_tools_payload(
32853297
}
32863298
schema["required"] = ["_confirm"]
32873299

3288-
func_decl["parametersJsonSchema"] = schema
3300+
func_decl[schema_key] = schema
32893301
else:
32903302
# No parameters provided - use default with required confirm param
32913303
# to ensure the tool call is emitted properly
3292-
func_decl["parametersJsonSchema"] = {
3304+
func_decl[schema_key] = {
32933305
"type": "object",
32943306
"properties": {
32953307
"_confirm": {
@@ -3531,31 +3543,8 @@ def _transform_to_antigravity_format(
35313543
first_func_seen = True
35323544
# Subsequent parallel calls: leave as-is (no signature)
35333545

3534-
# Claude-specific tool schema transformation
3535-
if internal_model.startswith("claude-sonnet-") or internal_model.startswith(
3536-
"claude-opus-"
3537-
):
3538-
self._apply_claude_tool_transform(antigravity_payload)
3539-
35403546
return antigravity_payload
35413547

3542-
def _apply_claude_tool_transform(self, payload: Dict[str, Any]) -> None:
3543-
"""Apply Claude-specific tool schema transformations.
3544-
3545-
Converts parametersJsonSchema to parameters and applies Claude-specific
3546-
schema sanitization (inlines $ref, removes unsupported JSON Schema fields).
3547-
"""
3548-
tools = payload["request"].get("tools", [])
3549-
for tool in tools:
3550-
for func_decl in tool.get("functionDeclarations", []):
3551-
if "parametersJsonSchema" in func_decl:
3552-
params = func_decl["parametersJsonSchema"]
3553-
if isinstance(params, dict):
3554-
params = inline_schema_refs(params)
3555-
params = _clean_claude_schema(params)
3556-
func_decl["parameters"] = params
3557-
del func_decl["parametersJsonSchema"]
3558-
35593548
# =========================================================================
35603549
# RESPONSE TRANSFORMATION
35613550
# =========================================================================

ā€Žsrc/rotator_library/providers/utilities/gemini_tool_handler.pyā€Ž

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,13 +456,17 @@ def _inject_signature_into_description(
456456
to help Gemini 3 use the correct parameter names.
457457
458458
Args:
459-
func_decl: Function declaration dict with name, description, parametersJsonSchema
459+
func_decl: Function declaration dict with name, description, and schema
460+
(either 'parametersJsonSchema' or 'parameters' key)
460461
description_prompt: Template string with {params} placeholder
461462
462463
Returns:
463464
Modified function declaration with signature appended to description
464465
"""
465-
schema = func_decl.get("parametersJsonSchema", {})
466+
# Support both parametersJsonSchema and parameters keys
467+
schema = func_decl.get("parametersJsonSchema") or func_decl.get(
468+
"parameters", {}
469+
)
466470
if not schema:
467471
return func_decl
468472

0 commit comments

Comments
Ā (0)