Skip to content

fix(models): sanitize tool schemas for Gemini compatibility#2887

Open
farukonfly wants to merge 1 commit into
bytedance:mainfrom
farukonfly:fix/gemini-tool-schema-sanitization
Open

fix(models): sanitize tool schemas for Gemini compatibility#2887
farukonfly wants to merge 1 commit into
bytedance:mainfrom
farukonfly:fix/gemini-tool-schema-sanitization

Conversation

@farukonfly
Copy link
Copy Markdown

Fix HTTP 400 errors caused by Gemini's strict validation via OpenAI gateways. Arrays now auto-fill missing items, and non-string enum values are safely moved to description.

❌ Before (Rejected): { "tags": { "type": "array" }, "retry": { "type": "integer", "enum": [1, 2, 3] } }

✅ After (Accepted): { "tags": { "type": "array", "items": { "type": "string" } }, "retry": { "type": "integer", "description": "... (valid values: 1, 2, 3)" } }

Fix HTTP 400 errors caused by Gemini's strict validation via OpenAI gateways. Arrays now auto-fill missing `items`, and non-string `enum` values are safely moved to `description`.

❌ Before (Rejected):
{
  "tags": { "type": "array" },
  "retry": { "type": "integer", "enum": [1, 2, 3] }
}

✅ After (Accepted):
{
  "tags": { "type": "array", "items": { "type": "string" } },
  "retry": { "type": "integer", "description": "... (valid values: 1, 2, 3)" }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant