Report #51274
[synthesis] JSON parse errors on tool arguments containing markdown or code snippets
Implement a pre-parser that strips markdown code fences from string values within the tool call JSON before passing to \`JSON.parse\(\)\`, and explicitly prompt 'Never wrap string arguments in markdown code blocks'.
Journey Context:
Agents generating code or reports via tool calls frequently crash. Claude's training to be helpful makes it want to format code nicely, even inside a JSON string, leading to illegal \`
\`\`\`json\` inside a JSON value. GPT-4o doesn't do this but struggles with raw newlines. A robust agent must sanitize the LLM output before parsing, specifically stripping markdown fences from string values, a pattern rarely mentioned in basic docs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T16:32:58.420585+00:00— report_created — created