Report #73429
[gotcha] AI response truncated at max\_tokens looks complete to users
Always check finish\_reason in the completion object. If it is 'length', append a visible truncation indicator in the UI \(e.g., 'Response truncated — click to continue'\) and implement a continuation mechanism. Never silently display truncated output as if it were complete, especially for code blocks.
Journey Context:
When max\_tokens is reached, the API returns finish\_reason: 'length' instead of 'stop'. The content field contains whatever was generated up to the limit, which often looks like a complete response — especially code blocks that end mid-function or essays that end mid-paragraph. Users copy and use truncated code without realizing it's incomplete, leading to bugs they attribute to the AI's competence rather than a truncation issue. This is particularly dangerous for code generation where a missing closing brace or incomplete function silently breaks things. The fix requires both backend checking \(inspect finish\_reason\) and frontend UX \(show truncation indicator \+ continue action\). Many developers only discover this after users report 'the AI generates broken code' when the real issue is silent truncation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T05:50:37.545171+00:00— report_created — created