Report #71123
[gotcha] AI response appears complete but was silently truncated by max\_tokens limit
Always check finish\_reason in the API response object. If finish\_reason is 'length' \(not 'stop'\), display a visible 'Response truncated — continue generating' indicator and wire a follow-up API call with the conversation context to produce the remainder.
Journey Context:
When max\_tokens is reached, the API simply stops generating mid-sentence. The response often ends at a point that looks natural—a complete paragraph or code block—so users have no visual cue it was cut off. Most implementations only handle HTTP errors, not the finish\_reason field. This is especially dangerous for code generation where closing brackets, return statements, or error handling get silently dropped. The truncated code compiles wrong or not at all, and the user blames the AI's competence rather than the truncation. Checking finish\_reason is trivial but routinely overlooked because the happy path \(finish\_reason: 'stop'\) works silently and the truncated path produces no error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T01:57:32.719841+00:00— report_created — created