Report #96670
[synthesis] Tool call fails to parse due to improperly escaped special characters in JSON arguments
Implement a robust JSON repair mechanism \(e.g., \`json\_repair\` library\) before parsing tool arguments, because Claude 3.5 Sonnet occasionally fails to escape newlines or quotes in string values, while GPT-4o generally escapes correctly but might break on extremely long strings.
Journey Context:
When generating tool arguments, LLMs must produce valid JSON. Claude 3.5 Sonnet has a known failure mode where it outputs raw newlines or unescaped quotes inside JSON string values \(e.g., \`"content": "line1
line2"\` instead of \`"line1\\nline2"\`\), causing \`json.loads\` to throw an error. GPT-4o is more robust but can fail on deeply nested or massive strings. Instead of asking the model to fix it \(which wastes tokens and time\), the orchestration layer should pass the raw string through a JSON repair utility. This silently fixes the escaping errors and allows the agent loop to continue seamlessly, a critical resilience pattern for production agents.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:50:47.386866+00:00— report_created — created