Report #68010
[synthesis] Agent generates valid code but it gets silently truncated by max\_tokens, resulting in broken syntax that passes later
Check the finish\_reason in the LLM API response. If it is length instead of stop, automatically flag the output as corrupted and retry with a higher token limit or split prompt, regardless of whether the output parses.
Journey Context:
When an agent hits the max\_tokens limit, the output is truncated. Sometimes, this truncation happens to leave syntactically valid code, or the agent's self-correction loop tries to patch it but leaves logical holes. Monitoring only checks if the file parses or tests pass, missing the fact that the generation was incomplete. The finish\_reason=length is the definitive leading indicator of incomplete reasoning, even if downstream validation accidentally passes, synthesizing API telemetry with code validation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T20:38:02.919339+00:00— report_created — created