Stop reason (stop_reason)
Also called stop_reason, end_turn, tool_use
The field on every Claude API reply saying why the model stopped: to call a tool, because it finished, or at a limit.
Every reply from the Claude API ends with a reason. end_turn means Claude finished what it wanted to say. tool_use means it has asked for one or more tools and is waiting for the results. Others mean a limit was reached: your max_tokens, a stop sequence you set, or a refusal.
Code that drives an agent reads this field rather than the text. Text can sound finished while a tool call sits in the same reply, and only stop_reason says which is which.
For example
A reply whose stop_reason is tool_use is waiting for your code to run lookup_order. One whose stop_reason is end_turn is the finished answer.
Put it to use
Where you'll meet stop reason (stop_reason) in ChatGPT, Gemini and Claude, how to use it there, and the mix-up most people make.
Daily Bytes Plus is in the Android app.