Report #90348
[synthesis] JSON parser fails on tool call output due to trailing text or whitespace
Use a robust JSON extraction regex \(like r'\\\{.\*\\\}' or a JSON5 parser\) rather than strict json.loads on the raw model output, as models append conversational text post-JSON.
Journey Context:
When using text-based tool calling or when models fail to use the native tool call API, GPT-4o generally stops generation after the closing brace. Claude 3.5 Sonnet frequently adds conversational text \(e.g., '\{"key": "value"\} Here is the result\!'\) or trailing newlines. A naive json.loads on the full string throws an error. Extracting the first valid JSON object from the string is necessary for cross-model resilience.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T10:14:38.168969+00:00— report_created — created