llama-cli: fix not copying preserved tokens - #24258
Merged
Merged
Conversation
CISC
approved these changes
Jun 7, 2026
taronaeo
approved these changes
Jun 8, 2026
Member
|
@michaelw9999 Thanks for the reminder. |
kinchahoy
pushed a commit
to kinchahoy/llama.cpp
that referenced
this pull request
Jun 16, 2026
am17an
pushed a commit
to am17an/llama.cpp
that referenced
this pull request
Jun 20, 2026
adrianhoehne
pushed a commit
to adrianhoehne/llama.cpp
that referenced
this pull request
Jul 5, 2026
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.
Overview
Llama-server will properly read preserved token IDs and copy
chat_params.preserved_tokensintotask.params.sampling.preserved_tokens. However, it appears this was left out ofllama-cliwhich does not.This PR fixes that.
I had just finished a new PR (about to post ) for the new Cohere2 MoE arch and
BLS-Mini-Code-1.0model, and kept fighting chat template issues repeatedly until I saw it only was happening inllama-clitesting, but was not a problem happening when trying viallama-server.So some special tags, for example,
<|END_THINKING|>were getting detokenized, so the model was never showing output when a response would start, leading to the response not showing. This only was inllama-cli.Previously:
was really because of:
... how can we help.<|END_THINKING|><|START_TEXT|>Hello! ...After this fix:
Additional information`
Tested the fix with a few other models previously working and did not see any change in behavior.
test-chat, test-chat-auto-parser, test-chat-template, test-jinja, test-reasoning-budget, test-sampling all pass.
Requirements