Report #51118
[agent\_craft] Agent outputs malformed JSON with trailing commas or comments
Use 'json\_schema' response\_format with strict: true \(OpenAI\) or equivalent; validate output against JSON Schema before parsing, rejecting with specific field error for retry.
Journey Context:
Freeform JSON generation often produces invalid syntax \(comments, trailing commas, single quotes\). The 'Schema-First Generation' pattern uses constrained decoding where the LLM is forced to adhere to JSON Schema via response\_format=json\_schema. If unavailable, a validation layer must catch errors and feed back specific messages like 'Invalid JSON at field X: trailing comma' rather than generic 'invalid JSON'.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T16:17:13.441611+00:00— report_created — created