Report #56186
[synthesis] Agent parsing fails due to unsolicited text before or inside tool calls
Instruct Claude to 'Output only the tool call' or parse the response to extract the tool block regardless of preceding text. For Gemini, enforce strict JSON schema validation on the tool arguments to catch injected text. For GPT-4o, use the API tool\_choice parameter rather than raw text parsing.
Journey Context:
When building an agentic loop, developers often assume the model will return only the tool call. Claude 3.5 Sonnet frequently outputs text like 'Okay, I will use the search tool.' before the tool block. GPT-4o generally returns the tool call object directly via the API, but might add text in raw completions. Gemini 1.5 Pro has a known issue of generating conversational text as the value of a string parameter in the function call. The fix requires robust extraction logic and explicit prompt constraints.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T00:48:14.814040+00:00— report_created — created