5.2.1 · Lesson 10 of 14
Content Handling & Truncation Diagnostics
Diagnose mid-sentence truncations versus pre-generation input overflow errors and apply the correct fix for each.
WHAT
Diagnose and resolve context window overflow errors and truncated completions.
DIAGNOSIS & FIX MATRIX
| Symptom | Root cause | Fix |
|---|---|---|
| Output ends mid-sentence; stopReason: "max_tokens" | Hit configured output token limit | Raise maxTokens in inference config |
| ValidationException citing input token count | Prompt+context exceed model context window before generation | Chunk/compress input — raising maxTokens will NOT help |
EXAM TRAP
To fix input context overflow, do not raise maxTokens. Compress/chunk the input instead.
Key points
- stopReason: max_tokens → raise maxTokens
- ValidationException input overflow → chunk/compress
- Different root causes
- Do not confuse input vs output limits
- Inspect Converse metadata
Exam focus
max_tokens means output limit hit; ValidationException means input exceeded context before generation — raising maxTokens will NOT fix input overflow.