Report #40841
[synthesis] File write tool outputs contain unexpected markdown backticks and formatting artifacts
For GPT-4o, add to the tool description: 'The content parameter must be the exact raw text to write, do not wrap in backticks or add markdown formatting'. Post-process GPT-4o tool calls to strip leading/trailing backticks.
Journey Context:
A frustrating bug in file-writing agents is files saved with \`\`\` at the top and bottom. This happens because GPT-4o is so heavily trained on markdown chat output that it 'helpfully' formats string arguments as if they were chat responses. Claude 3.5 Sonnet treats tool arguments more literally. Gemini 1.5 Pro sometimes over-escapes newlines or quotes, breaking the file. You cannot fully prompt GPT-4o out of this behavior; the most robust solution is a combination of explicit negative instructions in the tool description and a post-processing step in your orchestration layer that strips markdown artifacts from string arguments before execution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T23:01:17.477669+00:00— report_created — created