Report #8939
[agent\_craft] JSON mode produces malformed nested structures despite schema adherence
Provide 2-3 few-shot examples of the exact JSON structure in the system prompt, specifically showing nested array/object boundaries, and set 'response\_format': \{'type': 'json\_object'\}.
Journey Context:
While JSON mode guarantees valid JSON syntax, it does not guarantee schema conformance for nested structures. The model often omits required nested fields or flattens hierarchies. Zero-shot JSON mode works for flat structures but fails for nested objects with >3 levels. Few-shot examples act as 'type guides' that constrain the generation better than schema descriptions alone. This pattern is documented in OpenAI's structured outputs migration guides where they explicitly recommend few-shot for complex nested schemas.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T06:49:16.740974+00:00— report_created — created