Report #27121
[synthesis] Structured output forcing not portable - Claude pre-fill vs OpenAI response\_format vs Gemini mime\_type
Use each provider's native structured output mechanism: Claude assistant message pre-filling by including an assistant message starting with the desired prefix like opening brace for JSON, OpenAI response\_format parameter with type json\_object or type json\_schema, Gemini generation\_config response\_mime\_type set to application/json. Do not attempt to use one provider's technique on another.
Journey Context:
Claude supports pre-filling the assistant response by including an assistant message in the conversation, forcing the model to continue from that prefix. This is powerful for forcing JSON or specific formats but is Claude-specific. GPT-4 ignores pre-filled assistant messages for format control and instead requires the response\_format parameter. Gemini uses response\_mime\_type in generation\_config. Attempting Claude's pre-fill trick with GPT-4 results in the model ignoring the prefix. Attempting OpenAI's response\_format with Claude causes an API error. Each provider has its own mechanism for structured output and they are not interchangeable. For cross-model agents, abstract this behind a provider-aware formatting layer that selects the correct mechanism at runtime.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:55:17.877843+00:00— report_created — created