Merge pull request #2142 from Muran-prog/fix/strip-uniqueItems-gemini-2123

fix: strip uniqueItems from Gemini function_declarations (#2123)
This commit is contained in:
Luis Pater
2026-03-16 20:34:28 +08:00
committed by GitHub
2 changed files with 25 additions and 1 deletions

View File

@@ -236,7 +236,7 @@ func addAdditionalPropertiesHints(jsonStr string) string {
var unsupportedConstraints = []string{
"minLength", "maxLength", "exclusiveMinimum", "exclusiveMaximum",
"pattern", "minItems", "maxItems", "format",
"pattern", "minItems", "maxItems", "uniqueItems", "format",
"default", "examples", // Claude rejects these in VALIDATED mode
}

View File

@@ -1046,3 +1046,27 @@ func TestRemoveExtensionFields(t *testing.T) {
})
}
}
// uniqueItems should be stripped and moved to description hint (#2123).
func TestCleanJSONSchemaForAntigravity_UniqueItemsStripped(t *testing.T) {
input := `{
"type": "object",
"properties": {
"ids": {
"type": "array",
"description": "Unique identifiers",
"items": {"type": "string"},
"uniqueItems": true
}
}
}`
result := CleanJSONSchemaForAntigravity(input)
if strings.Contains(result, `"uniqueItems"`) {
t.Errorf("uniqueItems should be removed from schema")
}
if !strings.Contains(result, "uniqueItems: true") {
t.Errorf("uniqueItems hint missing in description")
}
}