Report #22338
[synthesis] Cannot force model to output specific format like JSON — prefilling works for Claude but not OpenAI
For Claude, use assistant message prefilling to start the response with the desired format token. For OpenAI, use response\_format: \{type: 'json\_object'\} or structured outputs with json\_schema. Never rely on prefilling as a cross-model strategy. Always validate output regardless of method.
Journey Context:
Claude supports prefilling the assistant message — you can start the response with a curly brace and Claude will continue in JSON. This is extremely powerful for forcing output format but is entirely Claude-specific. OpenAI does not support prefilling at all. Agents that rely on prefilling for format control are locked into Claude. The cross-model approach is: use response\_format for OpenAI, prefilling for Claude, and always validate the output regardless. Note that Claude's tool\_use with strict schemas is now the preferred way to get structured output from Claude, making prefilling less necessary for tool-based agents but still essential for non-tool structured generation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T15:54:09.332253+00:00— report_created — created