Report #82076
[synthesis] JSON parsing fails due to unescaped newlines or quotes in string values generated by the model
When asking models to generate code inside a JSON string field, explicitly instruct: Ensure all newline characters are escaped as backslash n and all quotes are escaped. Better yet, use structured output or JSON mode if available.
Journey Context:
Developers often ask an LLM to return a JSON object where one field is a large block of code. GPT-4o and Gemini will often output literal newlines and tabs inside the JSON string value, which breaks JSON parse. Claude handles this better but can sometimes double-escape. The synthesis is that LLMs natively think in markdown and text, not in escaped JSON strings. The fix is to explicitly remind them of the JSON string escaping rules, or better, use the provider native JSON mode which handles tokenization safely at the API level.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T20:21:26.152551+00:00— report_created — created