Fix Gemini tool schema required fields#570
Conversation
PR OverviewThis PR fixes a critical bug where Gemini API rejects tool schemas containing Problem StatementGemini's API strictly validates JSON Schema
Solution ArchitectureThe PR introduces a schema sanitization pipeline that:
Technical ImplementationNew Functions in
Modified Code Paths:
Test CoverageAdded comprehensive test in
Architecture Impactflowchart TD
A[Tool Schema Input] --> B{isPlainJsonSchemaObject?}
B -->|Yes| C[Clone Schema]
B -->|No Zod| D[Return Original]
C --> E[Recursive Sanitization]
E --> F[Filter Required Arrays]
F --> G[Visit Properties Map]
G --> H[Visit Items/Composition]
H --> I[Return Sanitized Schema]
I --> J{has _def property?}
J -->|Yes| K[Use as Zod]
J -->|No| L[Wrap with jsonSchema]
K --> M[Tool Registration]
L --> M
D --> M
Affected Components
Files Changed
References
Metadata
Powered by Visor from Probelabs Last updated: 2026-05-29T11:54:14.613Z | Triggered by: pr_opened | Commit: e790db9 💡 TIP: You can chat with Visor using |
Security Issues (3)
Security Issues (3)
Performance Issues (1)
Quality Issues (1)
Powered by Visor from Probelabs Last updated: 2026-05-29T11:41:48.194Z | Triggered by: pr_opened | Commit: e790db9 💡 TIP: You can chat with Visor using |
Summary
requiredentries that are not present in the same schema object'spropertiesmap, including nested object and array item schemasTests
npm test -- tests/unit/mcp-message-history.test.js --runInBandgit diff --checkCloses #569