Report #86848
[synthesis] Model adds conversational text before or after tool call JSON breaking parser
Use provider-specific \`tool\_choice\` enforcement and strip non-JSON tokens; for Claude, explicitly instruct 'Output only the tool call XML/JSON block with no preamble'; for GPT-4o, rely on \`strict\` mode or \`response\_format\` to suppress preamble.
Journey Context:
Claude 3.5 Sonnet frequently adds 'Certainly\!' before tool calls, while Gemini adds conversational text after. GPT-4o usually outputs pure JSON but occasionally adds text if \`strict\` is not enabled. A generic regex-based JSON extractor fails across models because Claude uses XML-like tags for tool calls in non-API contexts, and Gemini mixes text. The right call is enabling strict API features \(OpenAI\) and adding explicit negative prompting \(Claude\) rather than trying to parse mixed text/JSON responses.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:21:41.053415+00:00— report_created — created