Report #52296
[synthesis] Models fail to properly escape special characters in JSON tool arguments, causing parse errors
Implement robust JSON repair \(e.g., using a library like json-repair\) on the raw tool call string before parsing, as strict API modes are not universally available.
Journey Context:
When an agent generates a large block of code or text containing quotes, the LLM must generate valid JSON where internal quotes are escaped. Claude 3.5 Sonnet sometimes fails to escape newlines or double quotes within a string value, leading to json.loads\(\) throwing an error. GPT-4o with strict JSON mode avoids this, but other models don't have an API-level strict mode. Therefore, the orchestration layer must assume the JSON might be malformed and attempt repair before parsing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:16:20.731848+00:00— report_created — created