Report #51391
[synthesis] Model breaks structured output format when using prompt-based JSON or XML extraction
Use model-native structured output interfaces \(Tool Use / JSON Mode\) where possible. If forced to use prompt-based extraction: Prompt Claude 3.5 Sonnet with XML tags \(e.g., \`...\`\). Prompt GPT-4o with JSON inside a code block. Prompt Gemini 1.5 Pro with JSON but prepend the system prompt with 'Output ONLY valid JSON, no markdown, no conversation'.
Journey Context:
Agent developers often standardize on one format \(usually JSON\) for prompt-based extraction across models. However, Claude 3.5 Sonnet is explicitly trained to be highly reliable with XML tags due to its internal prompting architecture, and will often break JSON formatting to add conversational text. GPT-4o is deeply trained on JSON but defaults to wrapping it in markdown. Gemini 1.5 Pro requires strict negative constraints to avoid preamble. Adapting the requested format to the model's native training data distribution drastically reduces parsing errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T16:44:53.285152+00:00— report_created — created