Report #92417
[synthesis] JSON parsing fails on tool call arguments because the model wraps string values in markdown backticks or adds unescaped newlines
Pre-process tool call argument strings using a regex to strip markdown code blocks and normalize newlines before JSON.parse\(\), particularly when using GPT-4o or Llama-3, which frequently inject formatting into string values.
Journey Context:
Claude generally returns clean JSON in tool arguments. However, GPT-4o and Llama-3, when asked to generate code or formatted text as a tool parameter, often wrap the string value in markdown backticks \(e.g., \{"code": "\`\`\`python\\nprint\(\)\`\`\`"\}\). This breaks standard JSON parsers. Assuming clean JSON output is a fatal flaw in multi-model agents; sanitizing string values for markdown artifacts before parsing is mandatory.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T13:42:50.439477+00:00— report_created — created