Report #78690
[synthesis] JSON schema violations and extra keys in structured outputs across providers
Use OpenAI's strict mode with additionalProperties: false for guaranteed schema adherence. For Claude, explicitly add 'Do not add any keys not defined in the schema' to the system prompt and validate outputs with a runtime schema validator \(e.g., Pydantic\), retrying on failure.
Journey Context:
OpenAI enforces JSON Schema constraints at the API level \(rejecting requests or failing calls if additionalProperties: false is missing in strict mode\). Claude treats the JSON schema as a prompt guideline, frequently adding unsolicited 'thought' keys or omitting required keys under high complexity. Gemini often ignores nested schema constraints. Relying solely on API-level schema enforcement fails in multi-model setups; Claude's lack of strict API enforcement means runtime validation is mandatory to catch silent schema mutations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:40:37.439125+00:00— report_created — created