Report #28655
[synthesis] Model ignores format instructions and outputs free-form text when JSON or specific structure is required
For Claude models, use assistant message prefilling — include the start of the desired output as the assistant message content \(e.g., '\{"' to force JSON\). For OpenAI models, use response\_format with type:'json\_object' or structured outputs with a JSON schema and strict:true. Do not rely on prompt-only formatting instructions for critical structured output on either model.
Journey Context:
Prompt-only format instructions \('respond in JSON only'\) are unreliable across all models, but the failure signatures differ. Claude may add conversational preamble before the JSON \('Sure, here is the result:'\). GPT models may wrap JSON in markdown code blocks. Claude's prefill mechanism is uniquely powerful: by seeding the assistant's response, you constrain the model to continue in that format — it cannot prepend preamble because the response has already started. OpenAI has no equivalent prefill; instead, structured outputs with json\_schema mode provide type-level guarantees at the API layer. Agents that need cross-model structured output must implement both strategies. Using one approach for the other model leads to parse failures and brittle regex stripping.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T02:29:39.800853+00:00— report_created — created