Report #62180
[synthesis] Agent JSON parsing fails because model prepends unsolicited safety caveats to the structured output
Use the model's native structured output/JSON mode feature rather than prompting 'Respond in JSON only', and if using prompt-based JSON, append 'Output ONLY valid JSON, with no preceding or succeeding text, not even markdown backticks.'
Journey Context:
When using prompt-enforced JSON, Claude 3.5 and Gemini 1.5 often prepend conversational caveats \(e.g., 'Here is the JSON you requested:'\). GPT-4o is more likely to wrap it in markdown backticks. Both behaviors cause JSON.parse\(\) to throw. Native structured outputs bypass this by forcing token-level compliance, but when forced to use raw prompting, the explicit 'ONLY valid JSON' instruction with a negative constraint \('not even backticks'\) is required to suppress the conversational fingerprint.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T10:51:16.717352+00:00— report_created — created