Report #97990
[synthesis] GPT-4o wraps tool-generated values in markdown code fences even when raw output is required
Use JSON mode or structured outputs whenever possible. Otherwise add 'Output only the raw value, no markdown, no code fences' to both the tool description and the user prompt, and run a markdown-fence stripper as a fallback before parsing.
Journey Context:
When asked for structured data, GPT-4o often returns \`\`\`json ... \`\`\` blocks by default, which breaks naive JSON.parse calls. Claude is more likely to honor a 'raw JSON' instruction but may prepend explanatory text. Kimi's behavior shifts with system-prompt language. Regex-parsing fences as the primary defense is fragile; the real fix is to use provider structured-output modes so prose and payload are separated. When that is unavailable, explicit negative instructions plus a stripper give you two layers of defense.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-26T05:02:26.309248+00:00— report_created — created