Repository navigation
fix(frontend): gate SGLang tool-call parsing on delimiter token ids #17467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
c89bdee
98af701
cb5e59b
09b543d
3c40f83
44a185e
3ce2101
f969544
6fb4315
18883e4
fee2a19
07e5316
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -216,6 +216,7 @@ class FrontendConfig(RouterConfigBase, KvRouterConfigBase, AisPerfConfigBase): | |
| enable_streaming_reasoning_dispatch: bool | ||
| reasoning_field_name: str | ||
| exclude_tools_when_tool_choice_none: bool | ||
| isolate_tool_call_markers: bool | ||
| preprocess_workers: Optional[int] | ||
| tokenizer_backend: str | ||
| tokenizer_fallback: bool | ||
|
|
@@ -288,6 +289,10 @@ def validate(self) -> None: | |
| f"--tokenizer: invalid value '{self.tokenizer_backend}' " | ||
| f"(choose from {sorted(self._VALID_TOKENIZER_BACKENDS)})" | ||
| ) | ||
| if self.isolate_tool_call_markers and self.chat_processor != "sglang": | ||
| raise ValueError( | ||
| "--isolate-tool-call-markers requires --dyn-chat-processor=sglang" | ||
| ) | ||
| if self.ais_perf_config is not None and self.router_prefill_load_model != "ais": | ||
| raise ValueError( | ||
| "--ais-perf-config requires --router-prefill-load-model=ais" | ||
|
|
@@ -761,6 +766,21 @@ def add_arguments(self, parser) -> None: | |
| "tool calls in the content field." | ||
| ), | ||
| ) | ||
| add_negatable_bool_argument( | ||
| g, | ||
| flag_name="--isolate-tool-call-markers", | ||
| env_var="DYN_ISOLATE_TOOL_CALL_MARKERS", | ||
| default=False, | ||
| help=( | ||
| "Tokenize message content that contains the tool-call parser's " | ||
| "delimiters (for example a literal <tool_call> in a tool result) as " | ||
| "plain sub-words instead of the delimiter tokens, so the model cannot " | ||
| "copy a delimiter token out of untrusted input and have it parsed as " | ||
| "a real tool call. Requests whose content the chat template rewrites " | ||
| "are rejected rather than encoded unsafely. Requires " | ||
| "--dyn-chat-processor=sglang." | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] (7) The docs say it's off by default and should be evaluated per model; the help text, which operators see first, says neither. Suggestion: append "Off by default; evaluate against your model before enabling."
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in |
||
| ), | ||
| ) | ||
| add_argument( | ||
| g, | ||
| flag_name="--dyn-chat-processor", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] (8) Docs impact if the default flips to on.
@biswapanda as maintainer: the PR description asks whether this should default to on for the SGLang processor. Could you weigh in? If it flips, three places need to change together: the KB table default (
chat-processor.md), theParamFielddefault (frontend-configuration.mdx), and this--helptext.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed on the three places. Nothing changes in this commit: the default stays off until a maintainer decides. If it flips, I will update the KB table, the
ParamFielddefault and the--helptext in the same commit.