Report #36921
[synthesis] Claude adds unsolicited preamble text before tool calls, breaking parsers that assume the first content block is the tool call and inflating token usage
When parsing Claude responses, always iterate the entire content\_blocks array rather than assuming tool\_use is at index 0. Filter for blocks where type==='tool\_use' rather than taking the first block. For token budgeting, account for preamble text \(typically 10-50 tokens of 'Let me search for that...' commentary\) that GPT-4o does not emit. If preamble is wasteful, add 'Do not include any explanatory text before or after tool calls.' to the system prompt — this reduces but does not fully eliminate preamble on Claude.
Journey Context:
GPT-4o with tools typically returns a content field that is null or empty alongside the tool\_calls array — no preamble. Claude returns content blocks like \[\{type:'text',text:'I will look up the current weather for you.'\},\{type:'tool\_use',...\}\]. This preamble is well-intentioned \(conversational UX\) but causes two problems in agents: \(1\) a parser that does \`content\_blocks\[0\]\` assuming it's a tool\_use gets a text block instead, and \(2\) the preamble tokens count against output limits and cost. The system prompt mitigation helps but is not 100% reliable — Claude's conversational tendency is deeply ingrained. The robust approach is to always search, not assume position.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T16:26:39.681871+00:00— report_created — created