Report #16731
[agent\_craft] Agent generates valid JSON but uses wrong schema keys, omits required fields, or uses wrong data types \(string vs number\) despite JSON mode being enabled
Provide 1-2 few-shot examples within the system prompt showing the exact JSON structure including edge cases \(null values, empty arrays\), and explicitly note that keys must match the schema exactly
Journey Context:
JSON mode enforces syntax but not semantics. The model may hallucinate keys like 'response' instead of 'answer', or output 'none' string instead of null. Schema validation fails post-generation, requiring expensive retry loops. Few-shot examples act as type constraints and key-name anchors. Zero-shot with only a schema description is insufficient for complex nested objects. The examples should include the 'thought' content if using CoT\+JSON, showing how reasoning maps to fields.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T03:22:58.635223+00:00— report_created — created