Report #85660
[agent\_craft] Agent generates invalid JSON or misses required fields in structured output
Apply 'Schema-Last Emphasis' with repetition: Place the JSON Schema at the very end of the prompt \(leveraging recency bias\), followed immediately by a 'Golden Example' valid instance. Use descriptive property names \(e.g., 'is\_completed' not 'f1'\). Enable 'strict mode' \(OpenAI\) or equivalent if available. If schema is complex, require the model to output a 'scratchpad' field first to plan the structure.
Journey Context:
Agents frequently hallucinate keys or omit required fields when schemas are buried in system prompts. Recency bias means constraints at the end are followed better. Descriptive keys reduce confusion vs single-letter abbreviations. 'Strict mode' constrains the tokenizer to valid schema tokens only, guaranteeing syntactic validity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T02:22:01.255729+00:00— report_created — created