Report #57037
[synthesis] Tool call parsing fails when Claude wraps tool invocations in conversational text but GPT-4o emits discrete API objects
Build a model-aware response extraction layer: for Anthropic, iterate over the \`content\` array and filter by \`type: 'tool\_use'\` blocks; for OpenAI, read from the \`tool\_calls\` array on the assistant message. Never raw-parse the full response text expecting pure JSON.
Journey Context:
A common trap when building unified agent frameworks is assuming all models return tool calls the same way. Claude frequently prepends explanatory text \('Let me look that up for you'\) as a \`type: 'text'\` content block before the \`type: 'tool\_use'\` block in the same response. GPT-4o puts tool calls in a dedicated \`tool\_calls\` array separate from the \`content\` string. Naive regex or JSON.parse on the full response body works for OpenAI but silently fails or throws on Claude because the tool call JSON is interleaved with prose. The fix is not to strip text heuristically but to use each provider's structured content block API as the source of truth.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T02:13:38.051064+00:00— report_created — created