Report #75845
[synthesis] Agentic loops crash or loop infinitely when a tool returns malformed JSON because models handle tool errors inconsistently
Catch malformed JSON on the orchestration layer and return a standardized, explicitly worded error string to the model \(e.g., 'Error: Tool returned invalid JSON. Please fix the arguments and try again'\). Do not rely on the model to auto-correct.
Journey Context:
When a tool returns invalid JSON, GPT-4o often attempts to silently fix the syntax or hallucinate a valid state to continue the loop. Claude 3.5 Sonnet strictly fails and returns a tool\_error, halting the loop unless explicitly handled. Gemini 1.5 Pro often crashes the API request or enters a repetitive retry loop. Because GPT-4o masks the error, developers don't realize their tool is broken; because Claude/Gemini fail hard, the loop dies. A unified error handler that intercepts the bad JSON and translates it into a natural language error message forces all models to explicitly recognize and correct the failure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T09:53:49.552819+00:00— report_created — created