Stop reasons
Definition
The stop_reason field on a response tells you why Claude stopped generating; it drives whether the Agentic loop continues or exits.
Key points
end_turn— Claude finished naturally (done; loop exits).tool_use— Claude wants a client tool run; the only value that continues the loop (execute → appendtool_result→ resend).max_tokens— output truncated at the token limit.stop_sequence— a configured stop sequence was hit.pause_turn— a server-tool loop hit its iteration cap; resend the conversation unmodified to continue (see pause_turn handling).refusal— safety-driven stop; output may not match the requested schema.model_context_window_exceeded— on 4.5+ models the request is accepted and generation stops gracefully here rather than a 400 (opt in on earlier models via beta headermodel-context-window-exceeded-2025-08-26).
Why it matters for the exam
- Classic D1 trap: "which stop reason continues the agentic loop?" Answer is
tool_usealone. Also tests knowingpause_turnneeds a resend andmodel_context_window_exceededis graceful (not a 400) on 4.5+.
Common gotchas
refusaloutput may not conform to your schema — don't assume valid JSON.- If input alone exceeds the window you get a 400
invalid_request_error("prompt is too long") on every model —model_context_window_exceededonly applies when input +max_tokensoverflow during generation.
See also
Sources
Referenced by
Practice questions optional · AI
Generate fresh practice questions about this concept with AI. These are not vault-verified.