Report #43144
[synthesis] Agent generates valid JSON but truncation due to max\_tokens results in syntactically broken objects that fail silently downstream
Always set max\_tokens significantly higher than expected, and implement a fallback parser that attempts to close open JSON brackets or braces if a finish\_reason of length is detected.
Journey Context:
Developers set max\_tokens to save costs. The LLM generates a JSON array of results. If it hits the limit, it stops mid-array. The downstream JSON parser fails. Because the API returns a 200 OK with finish\_reason length, this isn't an API error. Teams that only monitor API error rates miss this entirely. The fix isn't just increasing tokens, but defensively parsing truncated outputs, which is a synthesis of cost-optimization and resilience engineering.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T02:53:37.726003+00:00— report_created — created