Skip to content

server: add --no-chat-input-special - #32033

Draft
ngxson wants to merge 2 commits into
masterfrom
xsn/input_marking_server
Draft

ngxson wants to merge 2 commits into
masterfrom
xsn/input_marking_server

Conversation

@ngxson

@ngxson ngxson commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Overview

Resolve #28249

Adding --no-chat-input-special which allows entering special tokens via chat endpoints, and the special tokens won't be parsed as special

This doesn't work correctly on all model, very dependent on the template itself. May need to have a validation logic to maybe reject or show warnings on template that doesn't work correctly

Requirements

@github-actions github-actions Bot added documentation Improvements or additions to documentation server labels Nov 10, 2026
thefallentree added a commit to thefallentree/llama.cpp-gp100 that referenced this pull request Nov 14, 2026
…nd in the parsed output

Input: the server tokenized the rendered chat prompt as one string with
parse_special, so a file the agent read and sent back as a tool result
turned "</think>", "<tool_call>", "<|im_end|>" into the special tokens.
llama_tokenize_with_literals() takes byte ranges in which no special token
is matched, not even a user-defined one (Qwen's <think> and <tool_call> are
USER_DEFINED and match even with parse_special = false). The text runs
between real special tokens are still tokenized as a whole, so the tokens
across the part borders are those of the whole text. The jinja input marking
(ggml-org#30389) gives the ranges; tokenize_chat_prompt() follows the shape of the
open upstream PR ggml-org#32033 (--chat-input-special / --no-chat-input-special),
also for the count-tokens endpoints and mtmd (mtmd_tokenize_from_parts joins
adjacent text parts and passes the literal ranges). Fork default: disabled,
client text is text; a request may set "chat_input_special".

Output: with the vocab's special token table, a PEG literal or until
delimiter that names a special token matches only that token id in the
generated tokens (ggml-org#29876), so "</think>" or "<tool_call>" written as
ordinary tokens in reasoning or content no longer cuts it. A small stand-in
for the token-aware parsing of the open upstream PR ggml-org#29307. Text without
tokens parses as before.

Refs: mkyt docs/decisions.md P6-50, P6-51; ggml-org#28249, ggml-org#32033, ggml-org#29307, ggml-org#29876, ggml-org#30389, ggml-org#28250.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
thefallentree added a commit to thefallentree/llama.cpp-gp100 that referenced this pull request Nov 17, 2026
…nd in the parsed output

Input: the server tokenized the rendered chat prompt as one string with
parse_special, so a file the agent read and sent back as a tool result
turned "</think>", "<tool_call>", "<|im_end|>" into the special tokens.
llama_tokenize_with_literals() takes byte ranges in which no special token
is matched, not even a user-defined one (Qwen's <think> and <tool_call> are
USER_DEFINED and match even with parse_special = false). The text runs
between real special tokens are still tokenized as a whole, so the tokens
across the part borders are those of the whole text. The jinja input marking
(ggml-org#30389) gives the ranges; tokenize_chat_prompt() follows the shape of the
open upstream PR ggml-org#32033 (--chat-input-special / --no-chat-input-special),
also for the count-tokens endpoints and mtmd (mtmd_tokenize_from_parts joins
adjacent text parts and passes the literal ranges). Fork default: disabled,
client text is text; a request may set "chat_input_special".

Output: with the vocab's special token table, a PEG literal or until
delimiter that names a special token matches only that token id in the
generated tokens (ggml-org#29876), so "</think>" or "<tool_call>" written as
ordinary tokens in reasoning or content no longer cuts it. A small stand-in
for the token-aware parsing of the open upstream PR ggml-org#29307. Text without
tokens parses as before.

Refs: mkyt docs/decisions.md P6-50, P6-51; ggml-org#28249, ggml-org#32033, ggml-org#29307, ggml-org#29876, ggml-org#30389, ggml-org#28250.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
thefallentree added a commit to thefallentree/llama.cpp-gp100 that referenced this pull request Nov 19, 2026
…nd in the parsed output

Input: the server tokenized the rendered chat prompt as one string with
parse_special, so a file the agent read and sent back as a tool result
turned "</think>", "<tool_call>", "<|im_end|>" into the special tokens.
llama_tokenize_with_literals() takes byte ranges in which no special token
is matched, not even a user-defined one (Qwen's <think> and <tool_call> are
USER_DEFINED and match even with parse_special = false). The text runs
between real special tokens are still tokenized as a whole, so the tokens
across the part borders are those of the whole text. The jinja input marking
(ggml-org#30389) gives the ranges; tokenize_chat_prompt() follows the shape of the
open upstream PR ggml-org#32033 (--chat-input-special / --no-chat-input-special),
also for the count-tokens endpoints and mtmd (mtmd_tokenize_from_parts joins
adjacent text parts and passes the literal ranges). Fork default: disabled,
client text is text; a request may set "chat_input_special".

Output: with the vocab's special token table, a PEG literal or until
delimiter that names a special token matches only that token id in the
generated tokens (ggml-org#29876), so "</think>" or "<tool_call>" written as
ordinary tokens in reasoning or content no longer cuts it. A small stand-in
for the token-aware parsing of the open upstream PR ggml-org#29307. Text without
tokens parses as before.

Refs: mkyt docs/decisions.md P6-50, P6-51; ggml-org#28249, ggml-org#32033, ggml-org#29307, ggml-org#29876, ggml-org#30389, ggml-org#28250.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
thefallentree added a commit to thefallentree/llama.cpp-gp100 that referenced this pull request Nov 19, 2026
…nd in the parsed output

Input: the server tokenized the rendered chat prompt as one string with
parse_special, so a file the agent read and sent back as a tool result
turned "</think>", "<tool_call>", "<|im_end|>" into the special tokens.
llama_tokenize_with_literals() takes byte ranges in which no special token
is matched, not even a user-defined one (Qwen's <think> and <tool_call> are
USER_DEFINED and match even with parse_special = false). The text runs
between real special tokens are still tokenized as a whole, so the tokens
across the part borders are those of the whole text. The jinja input marking
(ggml-org#30389) gives the ranges; tokenize_chat_prompt() follows the shape of the
open upstream PR ggml-org#32033 (--chat-input-special / --no-chat-input-special),
also for the count-tokens endpoints and mtmd (mtmd_tokenize_from_parts joins
adjacent text parts and passes the literal ranges). Fork default: disabled,
client text is text; a request may set "chat_input_special".

Output: with the vocab's special token table, a PEG literal or until
delimiter that names a special token matches only that token id in the
generated tokens (ggml-org#29876), so "</think>" or "<tool_call>" written as
ordinary tokens in reasoning or content no longer cuts it. A small stand-in
for the token-aware parsing of the open upstream PR ggml-org#29307. Text without
tokens parses as before.

Refs: mkyt docs/decisions.md P6-50, P6-51; ggml-org#28249, ggml-org#32033, ggml-org#29307, ggml-org#29876, ggml-org#30389, ggml-org#28250.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
thefallentree added a commit to thefallentree/llama.cpp-gp100 that referenced this pull request Nov 20, 2026
…nd in the parsed output

Input: the server tokenized the rendered chat prompt as one string with
parse_special, so a file the agent read and sent back as a tool result
turned "</think>", "<tool_call>", "<|im_end|>" into the special tokens.
llama_tokenize_with_literals() takes byte ranges in which no special token
is matched, not even a user-defined one (Qwen's <think> and <tool_call> are
USER_DEFINED and match even with parse_special = false). The text runs
between real special tokens are still tokenized as a whole, so the tokens
across the part borders are those of the whole text. The jinja input marking
(ggml-org#30389) gives the ranges; tokenize_chat_prompt() follows the shape of the
open upstream PR ggml-org#32033 (--chat-input-special / --no-chat-input-special),
also for the count-tokens endpoints and mtmd (mtmd_tokenize_from_parts joins
adjacent text parts and passes the literal ranges). Fork default: disabled,
client text is text; a request may set "chat_input_special".

Output: with the vocab's special token table, a PEG literal or until
delimiter that names a special token matches only that token id in the
generated tokens (ggml-org#29876), so "</think>" or "<tool_call>" written as
ordinary tokens in reasoning or content no longer cuts it. A small stand-in
for the token-aware parsing of the open upstream PR ggml-org#29307. Text without
tokens parses as before.

Refs: mkyt docs/decisions.md P6-50, P6-51; ggml-org#28249, ggml-org#32033, ggml-org#29307, ggml-org#29876, ggml-org#30389, ggml-org#28250.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
x1250 added a commit to x1250/llama.cpp that referenced this pull request Nov 22, 2026
…s session

Section 9.6, the registry and CLAUDE.md called upstream ggml-org#28249 a pull
request. It is the maintainer's tracking issue (input marking); its pull
request is ggml-org#32033, a draft that still splits the prompt on the published
media marker, so it does not replace the request-scoped marker.

The defect recorded next to the media marker is no longer only measured on
a synthetic message: the tool result that carried the marker in the
Director's session carries the chat template too, 26 strings of its 12
control tokens, and the later replies of that session were generated with
them as control tokens in the prompt. Counted with session_tags.py (counts
only) and reproduced without slots by special_in_text.py (a /props dump in
a tool result: 4036 tokens, 4345 as text).
…erver

# Conflicts:
#	tools/server/server.cpp
#	tools/server/tests/utils.py

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wiring up jinja input marking

1 participant