Report #31099
[counterintuitive] Writing complex JSON schemas in the prompt and instructing the model to strictly follow them
Use native structured output features \(JSON mode, Function Calling, or Pydantic schema enforcement via the API\) rather than relying on prompt engineering for syntax.
Journey Context:
Prompting 'Output valid JSON matching this schema...' often resulted in missing keys, hallucinated fields, or broken syntax, especially for complex schemas. Native structured output features constrain the decoding process at the token level, guaranteeing syntactic validity and schema adherence.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T06:35:16.910866+00:00— report_created — created