Repository navigation
server: quoted added spellings stay plain through the chat route with real tokenizers (#2399) - #2400
Merged
Merged
Conversation
… real tokenizers (TF_TOKENIZER_DIRS, #2399)
ashhart
force-pushed
the
lead/quoted-markers
branch
from
November 7, 2026 07:59
7e9cc39 to
5557407
Compare
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.
Part of #2399.
#2399 reports Qwen3.8-Flash-Next ending a reply where it quotes
<|im_end|>. Main already encodes request text with added-token spellings masked (core/tokenizer/tokenizer.zigencodeMasked, since #1117), and stops only on the end token's id, so the end in the report was drawn by the model. Our tests showed the mask with small fixture tokenizers. This one shows it with the real tokenizers and chat templates people report on.What it checks
server/quoted_markers_test.zig, run byzig build test-quoted-markers-host, reads the directories inTF_TOKENIZER_DIRS(:-separated,;on Windows), each holding a model'stokenizer.json,tokenizer_config.jsonand chat template. Unset, it skips with a message, so CI is unchanged.For each directory it builds a chat request through the chat route's own path (
openai.chatInput, thenchat.prepare, which renders and encodes as/v1/chat/completionsdoes): a user message, an assistant message with reasoning and a tool call, a tool result, and the tool offered. Then, one field at a time, every added-token spelling of that vocabulary is quoted in backticks in that field: the user message, the assistant message, the reasoning, the tool-call arguments, the tool result and the tool schema. For each it checks:<|im_end|>still encodes as its id.A second test keeps the refusal honest: input that main refuses with
UnsafeAddedTokenMaskis still refused.With the mask removed, the first test fails (396 id mismatches); with only the refusal removed, the second fails. Both restored.
Result
Run on macOS with Qwen3.8-Flash-Next and Qwen3.8-27B: 20 of 20 pass; without the variable, both skip. Both vocabularies have the same 33 added tokens (ids 248044 to 248076).
<|im_end|>(248046),<tool_call>(248058) and</tool_call>(248059) are added tokens;<|tool_call_begin|>is not, and encodes to 7 ordinary tokens. All 33 spellings stay plain text in all six fields.The tokenizer files are not in the repository. No engine or kernel code changes.