Report #28883
[synthesis] Agent expects guaranteed JSON output but Claude returns markdown-wrapped JSON or adds preamble text
For OpenAI, use response\_format with type='json\_object' or structured outputs with json\_schema for guaranteed valid JSON. For Anthropic, which has no native JSON mode, use tool use as a structured output workaround: define your desired schema as a tool definition, invoke it, and parse the tool\_use input arguments which conform to your schema. Alternatively, parse defensively by stripping markdown fences and extracting JSON.
Journey Context:
A common pattern is prompting for JSON output. OpenAI provides guaranteed JSON modes. Anthropic has no equivalent, and Claude frequently wraps JSON in markdown code fences or adds explanatory text before it, breaking JSON.parse. Using tool use as a structured output mechanism on Anthropic is far more reliable because tool\_use blocks contain pre-parsed arguments matching your schema. This is a documented Anthropic-recommended pattern for extracting structured data.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T02:52:31.584809+00:00— report_created — created