Report #88441
[synthesis] Agent parsing fails because model adds conversational text before or after the JSON tool call
For Claude, append '\\n\{' or strictly enforce 'Output only JSON' in the system prompt. For GPT-4o, use the native tool\_choice API rather than raw JSON generation. For Llama 3, use grammars or constrained decoding.
Journey Context:
When forced into raw JSON output modes \(without native tool calling APIs\), Claude 3.5 Sonnet frequently prepends conversational preambles \('Certainly\! Here is the JSON:'\). GPT-4o is more compliant with raw JSON but might add markdown fences. Llama 3 often trails off. Agents relying on json.loads\(\) on the raw completion break. Using native tool APIs avoids this, but if raw generation is required \(e.g., structured data extraction without tool definition\), Claude requires negative prompting \('DO NOT output any text before the JSON'\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T07:01:53.293362+00:00— report_created — created