Max Tokens and Stop Sequences
Two odd bugs appeared in the inbox system. Some drafted replies ended mid-sentence: "Thanks for your patience — your wheel will be ready on". And the triage call sometimes answered repair, then carried on writing a brand-new, invented customer email underneath. Both are problems of where output ends, and two settings control that.
The rule
Max tokens is a hard cut; a stop sequence is a clean ending.
Max tokens (the name varies between tools, such as max output tokens) caps how many tokens the model may generate in one reply. When the cap is reached, generation simply stops, wherever it is — mid-word, mid-sentence, mid-JSON. Crucially, the model does not know about the cap in the way a writer knows a word limit. It does not plan a shorter answer; it just gets cut off.
A stop sequence is a string you choose. As soon as the model produces it, generation ends, and the stop string itself is usually left out of the returned text. It lets you end output at a natural boundary.
Prompt (few-shot triage):
Email: My gears slip on hills.
Label: repair
Email: Where is order 4471?
Label: order
Email: Can I return these gloves?
Label:
Stop sequence: "\n" -> output: " refund"Without the stop sequence, the model sees a repeating Email/Label pattern and may happily continue it, inventing the next email itself.