stop_reason
APIDefinition
A field in the Claude API response indicating why the model stopped generating. Values: 'end_turn' (natural completion), 'max_tokens' (hit limit), 'stop_sequence' (hit custom stop), 'tool_use' (wants to call a tool). The primary signal for controlling agentic loops.
Example Usage
In agentic loops, check stop_reason: 'tool_use' means continue the loop, 'end_turn' means the task is complete.