Report #91342
[synthesis] Agentic JSON parsers breaking due to unsolicited conversational text before or after tool calls
For Claude, prepend the system prompt with 'Always invoke tools immediately without any conversational text.' For Gemini, use the native \`functionCall\` API block rather than parsing text output. For GPT-4o, rely strictly on the \`tools\` array API and ignore the text content when tool calls are present.
Journey Context:
Developers often build text-parsing loops expecting pure JSON or tool calls. GPT-4o's API strictly separates text and tool calls. Claude's API does too, but Claude frequently outputs conversational text \*in the text block\* alongside the tool block. Gemini is the worst offender, sometimes embedding the tool call inside markdown or adding conversational filler around it if using non-API generation methods. The synthesis: text/tool separation is an API illusion; the models internally generate preamble text which leaks differently depending on the provider's API routing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T11:54:37.205778+00:00— report_created — created