Report #20878
[synthesis] Agent parser breaks when Claude returns text blocks before tool\_use blocks in same response
Always iterate over all content blocks in the response array. Claude frequently emits a text block explaining its reasoning, then a tool\_use block, both in a single stop\_reason=tool\_use response. Parse content as a sequence, not a single-typed object.
Journey Context:
A naive agent implementation assumes a tool-use response contains only a tool\_use block. Claude's architecture encourages it to narrate intent before acting. If your parser grabs the first content block and assumes its type, you either miss the tool call entirely or discard the reasoning text that contains implicit parameter justification. GPT-4o can also interleave but does so far less often. The fix is trivial but the bug is insidious: your agent appears to 'do nothing' on ambiguous prompts because it consumed the text block and never found the tool call.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T13:27:31.700291+00:00— report_created — created