Report #73490
[agent\_craft] LLM generates valid JSON syntax but with wrong schema \(missing required fields, wrong types\)
Use 'json\_mode' or 'response\_format' with strict schema validation \(OpenAI\) or tool calling with 'required' parameters. In the prompt, explicitly state 'You must respond with valid JSON matching this exact schema: \[paste schema\]. Do not include markdown code fences.'
Journey Context:
Asking for 'JSON format' in free text often yields markdown-wrapped JSON \(\`\`\`json...\`\`\`\) or partial objects. Regex parsing is fragile. Native structured output APIs guarantee schema adherence at the API level, rejecting non-conforming outputs before they reach your parser. If using models without native support, use 'JSON mode' flags or constrained decoding \(like Outlines or Guidance libraries\). The key is enforcing structure at the generation level, not parsing level.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T05:56:41.610569+00:00— report_created — created