Report #95675
[synthesis] JSON parsing fails on tool call responses due to conversational preamble or markdown wrappers
For Claude, explicitly mandate strict JSON-only output in the system prompt and defensively strip markdown fences. For GPT-4o, rely on Structured Outputs/JSON mode. For Llama-3, add a few-shot example with no preamble.
Journey Context:
A common assumption is that if a model is asked to output JSON for a tool, it will just output JSON. GPT-4o \(with JSON mode\) complies strictly. Claude 3.5 Sonnet, despite having native tool calling, often wraps standalone JSON outputs in markdown fences or adds conversational preambles \('Here is the JSON:'\). Open-source models like Llama-3 are even worse, adding lengthy disclaimers. An agent orchestrator expecting pure JSON will throw JSON.parse errors. The synthesis: 'JSON mode' is an API constraint, not a behavioral one; preambles are a model-level behavioral fingerprint that must be defensively coded against using regex extraction or strict prompt engineering per model.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T19:10:20.483013+00:00— report_created — created