qwen36: decode the non-special added tokens (think and tool tags) - #1724
Merged
Merged
Conversation
Include tokenizer.json added_tokens in the ID-to-piece table so generated protocol tokens such as </think> and <tool_call> survive detokenization.
<think>, </think>, <tool_call> and <tool_response> are text the gateway parses. Special tokens (<|im_start|>, <|endoftext|>, <|im_end|>) keep decoding to nothing, as on dev and as reference decoding does with skip_special_tokens; decoding them would put chat markers in the text a client receives.
GenericRikka
pushed a commit
to GenericRikka/colibri
that referenced
this pull request
Sep 24, 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.
The decoder half of #1723 (GenericRikka), split out so it can ship in 1.12.1 while the tool-calling half is rebased.
The bug, on dev. Qwen3.6's
tokenizer.jsonkeeps<think>,</think>,<tool_call>,</tool_call>,<tool_response>and</tool_response>only inadded_tokens, not inmodel.vocab.load_tokenizerbuilt the id-to-piece table frommodel.vocabalone, so those ids decoded to zero bytes. The gateway splits reasoning from the answer on</think>in the engine's text, so with thinking on the closing tag never arrived and the whole answer was returned asreasoning_content.What changes.
added_tokens, and a real-adapter test pins the six protocol tokens against the full tokenizer.<|im_start|>,<|endoftext|>and<|im_end|>arespecial: trueand keep decoding to nothing, as on dev; without this the chat markers showed up in generated text.Measured on the real Qwen3.6-35B-A3B (ds, 60 tokens,
What is 2+2? Answer briefly.): dev prints the answer with the think block missing; with this PR the output carries<think>\n\n</think>before4, and no<|im_start|>or<|endoftext|>appears, exactly as on dev.test_qwen36_tokenizerpasses.