Report #70125
[synthesis] prompt asks for JSON output but Claude returns markdown-wrapped or conversational JSON
For guaranteed structured output: with GPT-4o, use response\_format=\{'type': 'json\_object'\} or Structured Outputs with JSON Schema. With Claude, use tool use as a structured output hack — define a single tool whose parameters match your desired output schema, and the model will populate it reliably. Never rely on prompt-only JSON instructions for Claude in production.
Journey Context:
OpenAI provides native JSON mode and Structured Outputs that guarantee valid JSON \(and even schema-conformant JSON\). Anthropic provides no equivalent feature. Prompting Claude to 'respond in JSON only' works most of the time but fails under edge cases: the model wraps JSON in markdown code blocks, adds conversational text before/after, or produces subtly invalid JSON \(trailing commas, unquoted keys\). The community-discovered workaround is to define a tool with your desired output schema and instruct Claude to use it — tool\_use output is always structurally valid because it must conform to the tool's input schema. This is a cross-model architectural pattern: use native structured output where available, fall back to tool-use-as-schema elsewhere.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:17:08.129670+00:00— report_created — created