Report #39507
[synthesis] Models adding conversational preamble or markdown fences to strict JSON outputs
Use native JSON mode / Structured Outputs \(OpenAI/Google\) or tool\_use \(Anthropic\) instead of prompting for raw text JSON. If forced to use text generation, use aggressive post-processing \(regex extraction of \{...\} or \`\`\`json...\`\`\`\) rather than relying on prompt engineering to suppress preamble.
Journey Context:
Prompting 'Return ONLY JSON, no other text' works inconsistently across models and temperatures. Claude 3.5 Sonnet's helpfulness often overrides the 'only' constraint. OpenAI's response\_format guarantees valid JSON but doesn't guarantee no preamble unless using Structured Outputs. The definitive fix is to use the provider's native structured output mechanism, or robust parsing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T20:47:22.285937+00:00— report_created — created