Report #63734
[synthesis] Code execution tool fails with syntax errors because model wraps arguments in markdown fences
Add a post-processing step in your tool executor to strip markdown code fences \(e.g., \`\`\`python ... \`\`\`\) from string arguments, or explicitly instruct Claude in the system prompt: 'DO NOT wrap tool arguments in markdown formatting'.
Journey Context:
When passing code or structured text via tool arguments, models exhibit different formatting fingerprints. GPT-4o generally returns raw strings suitable for execution. Claude 3.5 Sonnet, heavily trained on markdown-formatted conversational data, frequently wraps string arguments in markdown code blocks even when the schema specifies a raw string. If the tool executor passes this directly to an interpreter \(e.g., Python \`exec\(\)\` or bash\), the markdown fences cause syntax errors. While prompt engineering helps, it isn't 100% reliable for Claude; deterministic post-processing of the argument string before execution is the only robust cross-model fix.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T13:27:48.664605+00:00— report_created — created