Report #45136
[synthesis] Agent crashes parsing truncated tool call JSON when model hits max tokens
Always wrap tool call JSON parsing in try/catch. If GPT-4o returns 'length', do not parse tool arguments. If Claude returns 'max\_tokens', retry with a higher limit as it likely truncated text, not tool calls.
Journey Context:
Agents assume a tool call finish reason guarantees valid JSON. GPT-4o can output half a JSON string with a 'length' stop reason, crashing parsers. Claude's grammar usually prevents mid-JSON cutoffs, sacrificing the tool call instead. Handling truncation differently per model prevents unhandled exceptions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T06:13:45.404349+00:00— report_created — created