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)
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.
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.
In streaming (SSE) mode, stop_reason is given in the message_delta event, immediately before message_stop, rather than arriving with the first event.
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.
The LangChain September update enhanced SDK run tracing capabilities, adding capture of stop_reason values for Claude SDK runs.
stop_reason is a field in the Anthropic Claude API response, with common values including end_turn, max_tokens, and tool_use.
驱动Agent Loop循环的两个信号来自模型返回的stop_reason字段:当stop_reason等于tool_use时宿主执行工具并继续循环,否则循环退出
All Facts (7)
stop_reason is a field in the Anthropic Claude API response, with common values including end_turn, max_tokens, and tool_use.
65%UnverifiedThe 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.
50%UnverifiedThe 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.
50%UnverifiedIn streaming (SSE) mode, stop_reason is given in the message_delta event, immediately before message_stop, rather than arriving with the first event.
50%UnverifiedIn practice, stop_reason === 'tool_use' does not reliably reflect message structure: a response may contain a real tool call block yet report end_turn.
50%UnverifiedThe LangChain September update enhanced SDK run tracing capabilities, adding capture of stop_reason values for Claude SDK runs.
50%Unverified驱动Agent Loop循环的两个信号来自模型返回的stop_reason字段:当stop_reason等于tool_use时宿主执行工具并继续循环,否则循环退出
50%