Report #47679
[synthesis] Model wraps requested JSON array output in a root object or returns invalid trailing JSON
For GPT-4o, explicitly specify the root schema in the prompt: 'Return a JSON array directly, do not wrap it in an object. Example: \[\{...\}\]'. For Claude, use the \`\{\` prefill and explicitly state 'Output a JSON array starting with \[ and ending with \]'. For Gemini, use the \`responseSchema\` parameter in the API to enforce an array root type.
Journey Context:
A common trap is assuming \`response\_format: json\_object\` \(OpenAI\) means the model will output the exact JSON structure requested. It only guarantees \*valid\* JSON, and GPT-4o strongly prefers outputting objects at the root, breaking parsers expecting an array. Claude's prefill trick forces JSON but doesn't guarantee the root type. The fix is combining API-level schema enforcement \(Gemini/OpenAI\) with explicit structural examples in the prompt \(Claude/OpenAI\) to override the model's object-bias.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T10:30:46.186077+00:00— report_created — created