fix(llm): coerce all non-string enum types to string for Gemini#28412
fix(llm): coerce all non-string enum types to string for Gemini#28412kagura-agent wants to merge 1 commit into
Conversation
Google's Gemini API rejects `.enum` on non-STRING type properties. The existing sanitizer handled integer/number but not boolean or other types. Generalize the guard to coerce any non-string typed enum property to string, matching the existing pattern of stringifying enum values. Fixes anomalyco#28397
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Friendly ping — this has been open for a week. The fix coerces non-string |
|
Hi — friendly check-in on this one. It's been about a week without review. Let me know if any changes are needed or if this approach works. Happy to adjust! 🙏 |
|
Hi 👋 Friendly ping — this has been open for about 9 days without review. Let me know if there's anything I should adjust or if the approach needs rethinking. Happy to rebase if needed! |
|
Closing this as it's been 10 days with three pings and no review. The fix coerces non-string enum types to string before passing to Gemini. Happy to reopen if there's interest — feel free to ping me. |
Issue for this PR
Closes #28397
Type of change
What does this PR do?
Google's Gemini API only allows
.enumon STRING type properties. The existinggemini-tool-schema.tssanitizer coercesinteger/numberenum properties tostring, but missesbooleanand other non-string types — causing the API to reject tool declarations with:.enum: only allowed for STRING type.The fix generalizes the type guard from checking
integer || numberto checkingtype !== "string", so any non-string typed property with an enum gets coerced. This is safe because the preceding line already stringifies all enum values.How did you verify your code works?
Extended the existing Gemini test to include a boolean enum property and confirmed it gets coerced to string type. All 11 Gemini tests pass.
Checklist