Skip to content

Commit 3ad10fd

Browse files
committed
fix(rotator_library): 🐛 strip unsupported validation keywords for Gemini
Gemini's Proto-based API rejects exclusiveMinimum, exclusiveMaximum, and other JSON Schema validation keywords with "Unknown name" errors. Previously these were only stripped for Claude targets. Now stripped for all targets since neither API supports them.
1 parent bf2e634 commit 3ad10fd

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/rotator_library/providers/antigravity_provider.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -761,10 +761,10 @@ def _clean_claude_schema(schema: Any, for_gemini: bool = False) -> Any:
761761
# - "format" (export, date/time tools)
762762
# - "minimum"/"maximum" (range tools)
763763
#
764-
# Keywords to strip for Claude only (Gemini with 'parametersJsonSchema' accepts these,
765-
# but we now use 'parameters' key which may silently ignore some):
764+
# Keywords to strip for ALL targets (both Claude and Gemini):
765+
# Gemini's Proto-based API rejects these with "Unknown name" errors.
766766
# Note: $schema, default, examples, title moved to meta_keywords (always stripped)
767-
validation_keywords_claude_only = {
767+
unsupported_validation_keywords = {
768768
"minItems",
769769
"maxItems",
770770
"uniqueItems",
@@ -883,12 +883,9 @@ def _clean_claude_schema(schema: Any, for_gemini: bool = False) -> Any:
883883
if key == "const":
884884
continue
885885

886-
# Strip Claude-only keywords when not targeting Gemini
887-
if key in validation_keywords_claude_only:
888-
if for_gemini:
889-
# Gemini accepts these - preserve them
890-
cleaned[key] = value
891-
# For Claude: skip - not supported
886+
# Strip unsupported validation keywords for ALL targets (both Claude and Gemini)
887+
# Gemini's Proto-based API rejects these with "Unknown name" errors
888+
if key in unsupported_validation_keywords:
892889
continue
893890

894891
# Special handling for additionalProperties:
@@ -920,7 +917,7 @@ def _clean_claude_schema(schema: Any, for_gemini: bool = False) -> Any:
920917
for prop_name, prop_schema in value.items():
921918
# Log warning if property name matches a validation keyword
922919
# This helps debug potential issues where the old code would have dropped it
923-
if prop_name in validation_keywords_claude_only:
920+
if prop_name in unsupported_validation_keywords:
924921
lib_logger.debug(
925922
f"[Schema] Preserving property '{prop_name}' (matches validation keyword name)"
926923
)

0 commit comments

Comments
 (0)