Skip to content

Commit 98d493c

Browse files
committed
fix(rotator_library): šŸ› infer schema type during const-to-enum conversion
Gemini requires an explicit `type` definition when using `enum` in tool schemas. When converting unsupported `const` keywords to `enum`, the cleaner now automatically infers and injects the appropriate type (boolean, integer, number, or string) based on the constant value if it is missing.
1 parent 431f2d5 commit 98d493c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,9 +855,20 @@ def _clean_claude_schema(schema: Any, for_gemini: bool = False) -> Any:
855855
cleaned = {}
856856
# Handle 'const' by converting to 'enum' with single value
857857
# The 'parameters' key doesn't support 'const', so always convert
858+
# Also add 'type' if not present, since enum requires type: "string"
858859
if "const" in schema:
859860
const_value = schema["const"]
860861
cleaned["enum"] = [const_value]
862+
# Gemini requires type when using enum - infer from const value or default to string
863+
if "type" not in schema:
864+
if isinstance(const_value, bool):
865+
cleaned["type"] = "boolean"
866+
elif isinstance(const_value, int):
867+
cleaned["type"] = "integer"
868+
elif isinstance(const_value, float):
869+
cleaned["type"] = "number"
870+
else:
871+
cleaned["type"] = "string"
861872

862873
for key, value in schema.items():
863874
# Always skip meta keywords

0 commit comments

Comments
Ā (0)