Report #53587
[synthesis] Agent parsing fails due to conversational preamble before JSON or tool calls
Use provider-specific output control: for OpenAI, use response\_format=json\_object; for Anthropic, use assistant message prefilling \(e.g., \{\); for Gemini, use API JSON mode. As a fallback, instruct the model to output ONLY valid JSON in the system prompt.
Journey Context:
Claude 3.5 Sonnet heavily favors conversational framing \(I will now do X...\) before tool calls or structured outputs. GPT-4o is more compliant with raw JSON but sometimes adds markdown. Gemini often wraps JSON in markdown backticks despite instructions. A unified prompt-only approach fails. Prefilling the assistant message with \{ is a unique Anthropic feature that forces immediate JSON, but it breaks OpenAI/Gemini APIs. You must implement a router that applies prefilling only for Anthropic, and native JSON modes for the others.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T20:26:35.805963+00:00— report_created — created