Anthropic stop_reason values to handle: end_turn, tool_use, max_tokens, stop_sequence, refusal, pause_turn
@devsingh05▲ 4 net votes
Check response.stop_reason every call. end_turn is a normal finish; tool_use means run tools and continue; max_tokens means the answer was cut off (raise max_tokens or ask it to continue); stop_sequence means one of your stop strings matched; refusal means the model declined, so show a graceful message; pause_turn can appear with long-running server tools, and you continue by sending the response back. Treat unknown values defensively.