Why does a streaming response that hits max_tokens cause problems for the next turn's context?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
The model treats a mid-sentence echo as deliberate style.
Imagine someone is telling a story and gets cut off mid-sentence by the school bell. If you write that half-sentence into the textbook word for word, the next reader assumes the storyteller chose to stop right there. They will either start ending their own sentences the same broken way to match the style, or they will try to finish the sentence in a way that does not match what was about to come. The fix is to either put a clear note that says cut off here, or trim back to the last finished sentence and add three dots, or throw away the half-sentence and ask the storyteller to tell a shorter version this time. The middle option is the easiest and works almost always.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 minutes: explain why echo-verbatim corrupts next-turn quality, name the finish_reason field across providers, walk the three handling strategies, and identify trim to ellipsis as the cheap and safe default for chat.
| Strategy | When to use | Cost | Drawback |
|---|---|---|---|
| Explicit marker | Agent loops with programmatic next-turn logic | ~30 tokens overhead | Marker visible in chat UIs |
| Trim to clean boundary | Chat UIs with prose answers | Small information loss | User may want the partial content |
| Discard and retry | Structured outputs (JSON, tool calls) | Latency + double token spend | User waits longer for the answer |
| Echo verbatim (antipattern) | Never | Looks free | Model imitates the cutoff next turn |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Echoing the truncated assistant turn back into context verbatim. The model picks up the mid-sentence cutoff as a style cue and either repeats the pattern or fabricates a contradictory completion.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.