Report #86016
[synthesis] Agent JSON parsing fails repeatedly and prompts are tweaked unnecessarily when the real issue is silent token limit truncation
Check the finish\_reason in the LLM API response object. If it is length rather than stop, handle it as a truncation error \(e.g., request a continuation or reduce output size\) rather than a formatting or prompt error.
Journey Context:
When using structured output \(JSON mode\), if the model hits the max token limit, the API truncates the response mid-JSON. The agent's parser throws a JSONDecodeError. Developers see the parse error and assume the model is failing to follow the JSON format instructions, so they add more prompt examples emphasizing JSON syntax. This makes the problem worse by increasing the prompt size, leading to more truncation. The silent degradation is that the root cause \(token limits\) is masked by the symptom \(invalid JSON\). Checking finish\_reason immediately distinguishes model incompetence from model truncation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T02:57:59.857164+00:00— report_created — created