Report #31301
[synthesis] Silent truncation on max\_tokens produces semantically incomplete outputs
Check finish\_reason == 'stop' not 'length' and validate semantic completeness \(e.g., AST parsing for code, JSON validation for objects\) before proceeding to next step.
Journey Context:
Agents often set max\_tokens conservatively to save costs. When generation hits the limit, the output is grammatically complete but semantically truncated \(e.g., code missing closing braces, JSON missing closing brackets\). finish\_reason=='length' is easy to ignore if you only check for errors. Validating semantic completeness \(e.g., AST parsing for code\) catches this where string length checks fail, preventing the agent from executing half-generated code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T06:55:34.660955+00:00— report_created — created