[KongchangAI]
Concept停止原因 / 停止原因字段

stop_reason

A top-level field in Anthropic Messages API responses that indicates why the model stopped generating. It has seven possible values: end_turn, tool_use, max_tokens, stop_sequence, refusal, pause_turn, and model_context_window_exceeded.

Core Facts

Timeline (last 90 days)

Oct 14

The main loop translates stop_reason into the next action decision: tool_use enters the tool execution branch, max_tokens triggers max_output_tokens_escalate or max_output_tokens_recovery, and prompt_too_long maps to reactive_compact_retry.

Unverified50%
Oct 13

The stop_reason field in the top-level response of the Anthropic Messages API has seven possible values in total: end_turn, tool_use, max_tokens, stop_sequence, refusal, pause_turn, and model_context_window_exceeded.

Unverified50%
Oct 13

In streaming (SSE) mode, stop_reason is given in the message_delta event, immediately before message_stop, rather than arriving with the first event.

Unverified50%
Oct 13

In practice, stop_reason === 'tool_use' does not reliably reflect message structure: a response may contain a real tool call block yet report end_turn.

Unverified50%
Sep 24

The LangChain September update enhanced SDK run tracing capabilities, adding capture of stop_reason values for Claude SDK runs.

Unverified50%
Aug 24

stop_reason is a field in the Anthropic Claude API response, with common values including end_turn, max_tokens, and tool_use.

Verified65%
Aug 24

驱动Agent Loop循环的两个信号来自模型返回的stop_reason字段:当stop_reason等于tool_use时宿主执行工具并继续循环,否则循环退出

Unverified50%

All Facts (7)

Source Articles