Report #24245
[agent\_craft] JSON mode guarantees valid JSON but not schema compliance \(missing fields, wrong types\)
Use a two-stage validation: first call with JSON mode, then feed that output into a second prompt \(or same call with validation instructions\) that checks against required fields and types using natural language constraints, because JSON mode doesn't enforce specific keys beyond valid syntax.
Journey Context:
Developers trust \`response\_format: \{type: 'json\_object'\}\` to produce exactly the needed fields. But the model can omit keys or hallucinate extras. The Instructor library popularized 're-prompting' for validation. This is distinct from function calling \(which has schemas\) but applies when using JSON mode for output.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:06:20.503752+00:00— report_created — created