HackBlue

Tools · LLM application security · 13 / 23

The finish reason is why the reply stopped

The finish reason says whether the model ended the reply or the reply hit a length limit. Write it next to the text. A cut-off sentence is not a complete instruction.

11 min read · practice only with authorization

The field is the stop condition

An API response can include a finish reason beside the text. A reason that means the model stopped is not the same as a reason that means the output hit a length limit. The second one tells you the stored text may end in the middle of a sentence. The first one tells you the model chose an ending.

Neither reason makes the text true. Both tell you how the text ended. A note that omits the reason treats every reply as complete.

Do not act on a clipped ending

If the reason is a length limit, do not carry the last clause into a runbook as a finished step. The clause may be half a word. Quote the reason and say the reply is incomplete. A person can re-run with a higher limit or split the question. They should not complete the sentence themselves and file that completion as the model’s reply.

A tool status is still the tool’s line. A clipped reply that seems to describe a tool result is even less of a record than a finished reply, because you cannot see the whole sentence.

What to file

File the response id, the finish reason as printed, and whether you are treating the text as complete. If the reason is a length limit, file “incomplete” in the same line. Do not file a rewritten ending.

Worked case: a sentence cut off at the limit

Response r-512 from the lab roster bot ends “Book room B for the Fri” and the finish reason is length. A draft copies that into the schedule as a completed booking note and adds “day” so it reads cleanly.

The note quotes the finish reason, says the reply is incomplete, and does not add “day.” The schedule is unchanged. The stored text stays exactly as returned, with the reason beside it. A new request can ask the question again. This response is not a booking instruction.

Snippet
response: r-512
finish reason: length
text ends: "Book room B for the Fri"
complete: no
added by the reader: nothing
schedule change: none

Diagram

Read the finish reason before you use the text

The reason says whether the ending is the model’s.

  • Model stop

    The model ended the reply. The text can still be wrong. It is not clipped by the limit.

  • Length

    The reply hit a limit. The last words may be unfinished.

  • The note

    Write the reason. Mark length as incomplete.

  • Not allowed

    Finishing the sentence yourself and filing that as the reply.

Check yourself

1. The finish reason says the reply hit a length limit. What is the text?

2. A reader adds the missing word so the note reads cleanly. What is that word?

3. Why record the finish reason at all?