Did Claude's reply stop mid-sentence? Check stop_reason first
Every Messages API response has a stop_reason field that tells you why Claude stopped. If it says max_tokens, the reply hit the token limit you set and was cut off, so do not show it as complete.

You send a request to Claude, the response comes back with no error, and you show it to your user. But the reply stops mid-sentence, or the JSON you asked for is missing its end. The request succeeded, and the answer did not finish. This article covers the field that was telling you this all along, and how to check it before you show any reply.
What is stop_reason?
stop_reason is a field in every Messages API response that tells you why Claude stopped generating.
The stop reasons page in Claude's docs says to check this field to decide whether to use the response as-is, continue the conversation, retry, or fall back to another model. In other words, a successful request alone does not tell you the answer is complete.
Which values can stop_reason return?
stop_reason returns one value from the table in the docs, and each value means something different for the code that comes after it:
Value | When it occurs |
|---|---|
| Claude completed its response naturally |
| The response reached your |
| Claude emitted one of your |
| Claude is calling a tool |
| A server-tool loop reached its iteration limit |
| Claude declined to respond |
| The response filled the model's context window |
end_turn and stop_sequence show up when the reply stopped where you expect it to. The rest need your code to act.
What does max_tokens mean, and how do you catch it?
max_tokens as a stop_reason means Claude stopped because it reached the max_tokens limit you set in your request, so the reply is cut off.
The docs' Python example:
if response.stop_reason == "max_tokens":
# Response was truncated
print("Response was cut off at token limit")
# Consider making another request to continueIf the cut-off reply contains an incomplete tool use block, the same page says you need to retry the request with a higher max_tokens value to get the full tool use. A tool call with half its input is not something you can continue from.
model_context_window_exceeded is a different thing: Claude stopped because it reached the model's own context window limit, not the limit you set. The docs say this lets you request the maximum possible tokens without knowing the exact input size.
What should you do with a reply before users see it?
Before you show any reply, check stop_reason and send each value down its own path: a complete reply is shown, a cut-off one is flagged or continued, and a tool call is run.
The docs' best practices have a clear heading for it: always check stop_reason, and make it a habit in the code that receives the response. In practice:
end_turn: show the reply.max_tokensormodel_context_window_exceeded: the reply is incomplete. The docs suggest appending a notice so the reader knows the output is incomplete, or making another request to continue.tool_use: run the tool Claude asked for and send back its result.pause_turn: if you have an agent loop with server tools, add Claude's response to your messages and make another request to let it continue.refusal: do not show it as a normal answer, and decide what the user sees instead.
If you ask for JSON, item 2 matters most: cut-off JSON breaks your parser, and checking stop_reason first tells you why.
Where do you start now?
Search your project for every place that reads response.content from Claude directly, and add a stop_reason check before it. Start with the places that ask for JSON or run tools, because that is where a cut-off reply breaks something.
If you want to know how long your request is before you send it, see counting tokens before you send, and to cut the cost of instructions you repeat in every request, prompt caching. If you work with coding agents, take a look at AI skills.
How many places in your code show a Claude reply without asking why it stopped?
FAQ
Does a cut-off reply come back as an error?
No. The response comes back normally, and the only sign it was cut off is the stop_reason value, so your code has to check it.
What do I do if a tool call is cut off by max_tokens?
The docs say to retry the request with a higher max_tokens value to get the full tool use.
What is the difference between max_tokens and model_context_window_exceeded?
max_tokens means the reply reached the limit you set in the request. model_context_window_exceeded means the reply filled the model's own context window.


