Repository navigation
fix: stop cutting answers short (max_tokens 4096 → 16000) and flag cut-off replies - #4
Merged
Merged
Conversation
max_tokens was 4096, and adaptive thinking counts toward it, so long answers and research reports stopped mid-sentence with stop_reason max_tokens. The default is now 16000, under the Anthropic SDK's non-streaming ceiling of about 21,333. A reply that still hits the limit ends with a note, and every model call logs its stop reason and usage. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XtW6Y5JF5GNt1txL7PriFg
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Answers stopped mid-sentence. The cause was the app's own output cap, not the model's:
max_tokenswas 4096, and Claude Haiku 5.5's adaptive thinking counts toward that cap. Long answers and research reports ran out and stopped withstop_reason: "max_tokens", with no sign to the user. The model itself allows up to 128k output tokens.Changes
LLM_MAX_TOKENSdefault raised from 4096 to 16000. This stays under the Anthropic SDK's ceiling for non-streaming calls (about 21,333 tokens, above which it requires streaming). Checked as accepted for Haiku 5.5, Sonnet 5.5 and Opus 5.5. You pay only for tokens used.stop_reasonand token usage, so cut-offs show up in the Vercel logs.Verification
pytest -q: 40 passed (new tests for cut-off chat replies and reports, and forhit_length_limit)ruff check app tests: passesGenerated by Claude Code