---
title: "Did Claude's reply stop mid-sentence? Check stop_reason first"
description: "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."
url: https://ihsanalapsi.dev/articles/claude-stop-reason-max-tokens
lang: en
date: 2026-11-08
updated: 2026-11-08
tags: ["AI", "Developer tools"]
author: Ihsan Alapsi (إحسان العبسي)
---
# Did Claude's reply stop mid-sentence? Check stop_reason first

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](https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons) 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                                 |
| ------------------------------- | ---------------------------------------------- |
| `end_turn`                      | Claude completed its response naturally        |
| `max_tokens`                    | The response reached your `max_tokens` limit   |
| `stop_sequence`                 | Claude emitted one of your `stop_sequences`    |
| `tool_use`                      | Claude is calling a tool                       |
| `pause_turn`                    | A server-tool loop reached its iteration limit |
| `refusal`                       | Claude declined to respond                     |
| `model_context_window_exceeded` | 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:

```python
if response.stop_reason == "max_tokens":
    # Response was truncated
    print("Response was cut off at token limit")
    # Consider making another request to continue
```

If 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:

1. `end_turn`: show the reply.
2. `max_tokens` or `model_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.
3. `tool_use`: run the tool Claude asked for and send back its result.
4. `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.
5. `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](/articles/claude-token-counting), and to cut the cost of instructions you repeat in every request, [prompt caching](/articles/claude-prompt-caching). If you work with coding agents, take a look at [AI skills](/products/c/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.
