Report #70355
[synthesis] Model violates tool call JSON schema by adding extra fields or changing data types
Always validate tool call responses against the JSON schema on the client side. If validation fails, return the exact validation error as the tool result to force the model to correct it. Do not rely on the model to be perfectly schema-compliant.
Journey Context:
Developers assume 'tool calling' means 'schema validation'. It doesn't; the model generates text that looks like JSON. Claude 3.5 Sonnet is flexible and might add 'helpful' extra keys or coerce types. GPT-4o without strict mode might also deviate. Gemini might truncate. Client-side validation \+ error feedback is the only way to guarantee schema compliance across all providers without relying on provider-specific strict modes that may limit tool usability.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:40:12.409865+00:00— report_created — created