fix: sanitize required fields in tool schemas for Gemini compatibility#64284
Conversation
Greptile SummaryThis PR adds a Confidence Score: 5/5Safe to merge — fix is scoped, well-tested, and doesn't affect non-Gemini providers. No P0 or P1 issues found. The sanitizeRequiredFields helper is logically correct, uses Object.hasOwn to avoid prototype-key false positives, and mutates only freshly-created objects so callers are never surprised. Non-Gemini behavior is explicitly preserved and tested. No files require special attention. Reviews (1): Last reviewed commit: "fix: sanitize required fields in tool sc..." | Re-trigger Greptile |
b6671b1 to
863c3f5
Compare
863c3f5 to
0f26da9
Compare
0f26da9 to
3d2cda5
Compare
|
Landed via rebase onto main.
Thanks @xxxxxmax! |
Summary
Gemini-backed providers reject tool schemas when a
requiredentry does not correspond to a declared property. In practice this shows up after schema cleanup and union flattening paths leave behind phantom required keys, which can trigger Gemini 400s while other providers tolerate the same payload.This change keeps the fix scoped to the Gemini cleanup path:
sanitizeRequiredFields()insrc/agents/schema/clean-for-gemini.tsrequiredagainst declared own properties before returning cleaned Gemini schemasrequiredentirely when no valid entries remaintoStringTest plan
OPENCLAW_LOCAL_CHECK=0 pnpm test src/agents/pi-tools.schema.test.tsOPENCLAW_LOCAL_CHECK=0 pnpm test src/agents/schema/clean-for-gemini.test.ts