[KongchangAI]
Conceptstop_reason / finishReason / 停止原因

finish_reason

A field in LLM API responses that identifies the reason a model stopped generating output. Common values include natural completion (stop/end_turn), length truncation (length/max_tokens), and content filtering (content_filter/SAFETY), allowing callers to determine whether the model completed its output normally.

Core Facts

Timeline (last 90 days)

Oct 17

Common values of the finish_reason field include stop (natural end) and length (truncated upon reaching the maximum token count).

Unverified50%
Oct 17

Checking response integrity should verify both that finish_reason is stop and that the key data structure matches expectations (e.g., items is a non-empty list).

Unverified50%
Oct 16

Production routing logic should not look only at the HTTP status code, but should also check whether finish_reason and content are non-empty, and treat finish_reason of length with empty content as a hard failure rather than a parseable result.

Unverified50%
Oct 12

Streaming output combined with incremental validation can trigger an immediate alert or retry upon detecting finish_reason: length, without having to wait for the entire response to return.

Unverified50%
Oct 12

finish_reason should be logged together with call costs and plotted on the same monitoring dashboard to improve observability.

Unverified50%
Oct 12

A finish_reason value of length or MAX_TOKENS means the model was forcibly interrupted rather than concluding on its own.

Verified65%
Oct 12

Author Serguey Asael Shinder recommends reading the stop reason after every LLM call, just as one would read an HTTP status code.

Unverified50%
Oct 11

Only responses with a finish_reason of stop or tool_calls should be cached; responses truncated by length or those that errored should not be cached.

Unverified50%
Oct 7

When large language model APIs return responses, they typically include a finish_reason field with common values including stop, length, and tool_calls.

Unverified50%

All Facts (9)

Verified

A finish_reason value of length or MAX_TOKENS means the model was forcibly interrupted rather than concluding on its own.

65%
Unverified

Common values of the finish_reason field include stop (natural end) and length (truncated upon reaching the maximum token count).

50%
Unverified

Checking response integrity should verify both that finish_reason is stop and that the key data structure matches expectations (e.g., items is a non-empty list).

50%
Unverified

Production routing logic should not look only at the HTTP status code, but should also check whether finish_reason and content are non-empty, and treat finish_reason of length with empty content as a hard failure rather than a parseable result.

50%
Unverified

finish_reason should be logged together with call costs and plotted on the same monitoring dashboard to improve observability.

50%
Unverified

Author Serguey Asael Shinder recommends reading the stop reason after every LLM call, just as one would read an HTTP status code.

50%
Unverified

Streaming output combined with incremental validation can trigger an immediate alert or retry upon detecting finish_reason: length, without having to wait for the entire response to return.

50%
Unverified

Only responses with a finish_reason of stop or tool_calls should be cached; responses truncated by length or those that errored should not be cached.

50%
Unverified

When large language model APIs return responses, they typically include a finish_reason field with common values including stop, length, and tool_calls.

50%

Source Articles