Repository navigation
fix(server): a reply gets the context its prompt leaves instead of a 400 - #842
Merged
Merged
Conversation
Clients send their usual output cap whatever the prompt: Claude Code asks for 32000 tokens on every turn. Once prompt + max_tokens passed the context, the request was refused with 400, so with a 131072-token context and the model cards' 32768 default a session stopped working at about 99K tokens of prompt, long before the context was full. A direct request's max_tokens is now trimmed to the context its prompt leaves, as llama.cpp does with n_predict; a prompt that fills the context is still refused. A routed request keeps the old rule, so the router can still send it whole to a model with room for it. Thinking budgets follow the trimmed cap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
davide221
commented
Oct 13, 2026
davide221
left a comment
Contributor
Author
There was a problem hiding this comment.
Code review
No issues found. Checked for bugs and logic errors in the changed code.
Reviewed 7b8d0f55 · 0 candidate issues checked, kept at ≥70% confidence · add the code-review label to review again
davide221
added a commit
to Graffioh/lucebox-hub
that referenced
this pull request
Oct 13, 2026
Resolve the conflict with Luce-Org#842. validate_request_context keeps main's routed flag and its reply trim, and sends this branch's PFlash maximum-context error when compression would run. test_admission keeps both sets of tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Clients send their usual output cap whatever the prompt: Claude Code asks for 32000 tokens on every turn. Once prompt +
max_tokenspassed the context, the server refused the request with a 400. With a 131072-token context and the model cards' 32768 default, a session stopped working at about 99K tokens of prompt, long before the context was full.What changes
max_tokensis trimmed to the context the prompt leaves (fit_reply_to_contextinadmission.h), as llama.cpp does withn_predict. The server logs the trim.Measured
Qwen 3.8 27B on an R9700, launched with the model card's 32768 default instead of a fixed 4096:
max_tokens32000reasoning_effort: mediumthinking.budget_tokens2048The last two rows depend on the launcher dropping its fixed 4096 cap. This change is what makes dropping it safe for long prompts.
Tests
test_admission: a new case covers the trim and the refusal of a prompt that fills the context.test_server_unitpasses on a HIP build.🤖 Generated with Claude Code