Skip to content
47% off: the complete course for $79 (reg. $149)Order now →
Agent Builder

AI agent glossary

Stop reason

A field in a model's response that says why it stopped generating, such as finishing its turn, requesting a tool, or hitting the token limit.

Every response from a model API ends for a reason, and your agent loop should check it. In the Anthropic Messages API the field is stop_reason. The most common values are end_turn, meaning the model is done; tool_use, meaning it wants you to run one or more tools; and max_tokens, meaning it ran out of output budget mid-response. A few other values cover cases such as hitting a custom stop sequence.

The stop reason is how a minimal agent loop decides what to do next. On tool_use, run the tools and continue. On end_turn, return the answer. On max_tokens, the output is cut off, so either raise the limit, ask the model to continue, or treat it as an error rather than passing truncated output downstream.

Other providers expose the same idea under different names, such as a finish reason. Whatever it is called, branching on it explicitly makes agents far easier to debug than guessing from the content.

Learn more in the course

Related terms

Go from definitions to doing

Learn to use and build AI agents in 65 practical lessons.