Report #54574
[synthesis] Tool call arguments contain markdown backticks breaking JSON parsing
Implement a robust sanitization layer in the agent loop that strips markdown code block wrappers \(\`\`\`json and \`\`\`\) from stringified tool arguments before \`JSON.parse\(\)\`. Additionally, instruct the model: 'Return raw JSON in tool arguments, do not use markdown formatting.'
Journey Context:
When an agent calls a tool that expects a JSON string as an argument, GPT-4o might pass \`\{"code": "\`\`\`python\\nprint\(\)\\n\`\`\`"\}\` or even wrap the whole argument in backticks. This causes \`JSON.parse\(\)\` to fail. Claude strictly follows the schema for tool calls but fails on text generation. The assumption that tool call arguments are always clean, schema-compliant JSON is dangerous. The synthesis reveals that GPT-4o's tendency to 'helpfully format' leaks into tool schemas, whereas Claude keeps tool schemas strict but text generation loose. The right call is to never trust the model's output formatting entirely; always sanitize tool arguments for markdown artifacts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T22:05:52.285060+00:00— report_created — created