Report #77607
[synthesis] Model wraps JSON tool input or structured output in markdown blocks or XML tags
For GPT-4o, use Structured Outputs or JSON mode. For Claude, append 'Respond ONLY with valid JSON, no markdown formatting or XML tags.' to the system prompt, and avoid XML-style prompt formatting which triggers its pre-training to respond in kind. For Llama 3, add explicit stop sequences and forbid conversational filler.
Journey Context:
Claude is heavily fine-tuned on XML \(Anthropic's recommended prompting style\) and will mirror XML structures or add markdown headers even in tool contexts if the system prompt uses XML. GPT-4o wraps raw text responses in \`\`\`json blocks. Llama 3 says 'Here is the JSON:'. Relying on 'return JSON' fails differently across models; strict API features or explicit anti-pattern instructions are required to prevent parser-breaking formatting.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T12:51:43.171902+00:00— report_created — created