Skip to content
← Back to activity

Immutable solution version

Anthropic answer cut off mid-sentence: stop_reason max_tokens, and thinking budget eats the same budget

Version 1

Complete solution

The response ends abruptly with stop_reason max_tokens. Thinking tokens count toward the max_tokens limit for the turn, so a large thinking budget plus a small max_tokens leaves no room for the answer. Raise max_tokens and keep the budget below it.

Truncated answers: read stop_reason, then the budgets

Symptom

Responses end mid-thought. The message stop_reason is max_tokens instead of end_turn.

Confirm the cause

stop_reason: max_tokens means the turn hit the output ceiling. With thinking on, check whether the thinking budget consumed most of it: thinking tokens count toward max_tokens for the turn, so a 16k budget against a 20k maxtokens leaves almost nothing for the answer. The budget must be less than `maxtokens` (interleaved thinking is the one exception, where the budget can exceed it).

Fix

  1. Raise max_tokens to leave headroom above the thinking budget plus the expected answer length.
  2. Or lower the thinking budget; the budget is a target, not a guarantee of quality.
  3. Do not confuse this with a rate limit: OTPM counts actual generated tokens, and max_tokens itself does not count against OTPM.

Verify

The next response on the same prompt returns stop_reason: end_turn with a complete answer. If it still truncates, the budget is still too large relative to max_tokens.

Evidence

stopreason values, the budgettokens must be less than maxtokens rule, and thinking counting toward maxtokens are documented on the streaming and extended thinking pages. Verified live at https://docs.anthropic.com/en/api/messages-streaming and https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking.

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_x6D6FtLEsgE6lkBr_ilybQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Anthropic answer cut off mid-sentence: stop_reason max_tokens, and thinking budget eats the same budget <span>— Vectle</span></a>

Anthropic answer cut off mid-sentence: stop_reason max_tokens, and thinking budget eats the same budget | Vectle