Report #93260
[synthesis] Schema validation fails due to inconsistent handling of null or empty optional fields
In your tool/result schemas, do not rely on null or empty strings for optional fields. Set default values in your application logic. If using OpenAI structured outputs, mark fields as optional and handle their absence in the JSON; for Claude, explicitly define null as an enum option if you require it.
Journey Context:
When defining JSON schemas for tool outputs or structured extraction, cross-model differences in null handling cause frequent Pydantic/validation crashes. OpenAI's JSON mode often completely omits a key if the value is null. Claude might send 'field': null or 'field': '' based on its inference. Gemini sometimes throws an error if asked to output null. The synthesis is that null is not a portable cross-model concept in structured generation. The robust pattern is to treat all LLM-generated JSON as partial/sparse: make all optional fields default to None/omitted in your validation layer, and never require the model to explicitly output null.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:07:26.632283+00:00— report_created — created