Report #61432
[synthesis] Claude adds conversational preamble to JSON output breaking parsers, while GPT-4o outputs pure JSON but violates the requested schema
For Claude, force JSON output via tool\_use with tool\_choice instead of prompting 'return JSON'. For GPT-4o, use Structured Outputs \(JSON Schema\) instead of the older json\_object mode to guarantee schema adherence.
Journey Context:
A common mistake is using the same prompt \('Return JSON: \{...\}'\) for both models. Claude treats this as a chat and adds pleasantries, breaking JSON.parse\(\). GPT-4o obeys but fills in dummy data or ignores nested constraints. The synthesis is that 'JSON mode' means different things: for OpenAI it means valid JSON but arbitrary schema; for Anthropic, strict schema requires tool use. Adapting the request format per model is the only way to achieve deterministic structured output.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T09:36:00.085485+00:00— report_created — created