sgl-project/sglang · critical · ValueError
--enable-strict-thinking requires a grammar backend that sup
Error message
--enable-strict-thinking requires a grammar backend that supports token filtering, but grammar_backend='none' was specified. Use --grammar-backend xgrammar or another backend that supports token filtering.
What it means
--grammar-backend none explicitly disables grammar/constrained decoding, but --enable-strict-thinking requires token filtering, which the 'none' backend cannot provide, so create_grammar_backend raises this configuration error at startup.
Source
Thrown at python/sglang/srt/constrained/base_grammar_backend.py:417
f"Grammar backend disabled because tokenizer is not supported by XGrammar: {e}. "
"Falling back to grammar_backend='none'. "
"Structured outputs (JSON schema, regex, EBNF) will not be available."
)
get_context().override("grammar.import_fallback", grammar_backend="none")
return None
elif name == "llguidance":
from sglang.srt.constrained.llguidance_backend import GuidanceBackend
grammar_backend = GuidanceBackend(
tokenizer=tokenizer,
any_whitespace=not get_serving().constrained_json_disable_any_whitespace,
whitespace_pattern=get_serving().constrained_json_whitespace_pattern,
n_vocab=vocab_size,
eos_token_ids=eos_token_ids,
)
elif name == "none":
if get_serving().enable_strict_thinking:
raise ValueError(
"--enable-strict-thinking requires a grammar backend that supports "
"token filtering, but grammar_backend='none' was specified. Use "
"--grammar-backend xgrammar or another backend that supports token "
"filtering."
)
return None
else:
raise ValueError(f"Invalid grammar backend: {name}")
if get_serving().reasoning_parser and think_end_ids:
from sglang.srt.constrained.reasoner_grammar_backend import (
ReasonerGrammarBackend,
)
reasoning_parser = ReasoningParser(
model_type=get_serving().reasoning_parser,
stream_reasoning=False,
tokenizer=tokenizer,View on GitHub (pinned to 0132848349)
Solutions
- Remove --enable-strict-thinking if you want grammar_backend='none'
- Change to --grammar-backend xgrammar (or another token-filtering backend) to keep strict thinking
- Audit scripts/launch configs for conflicting flags
Example fix
# before --grammar-backend none --enable-strict-thinking # after --grammar-backend xgrammar --enable-strict-thinking
Defensive patterns
Strategy: validation
Validate before calling
if server_args.grammar_backend == 'none':
assert not server_args.enable_strict_thinking, 'strict thinking requires a token-filtering grammar backend' Prevention
- Centralize flag-compatibility checks in a validate_server_args step
- Document flag matrix; grep launch scripts for both flags before deploying
When it happens
Trigger: Passing both --grammar-backend none and --enable-strict-thinking on the server command line or ServerArgs.
Common situations: Users disabling the grammar backend to save startup time or avoid xgrammar issues, while separately enabling strict thinking; contradictory flags copied from different runbooks.
Related errors
- --enable-strict-thinking requires a grammar backend with tok
- Invalid grammar backend: {name}
- world_size ({world_size}) is less than tensor_parallel_degre
- think_end_token '{reasoning_parser.detector.think_end_token}
- Strict reasoning format requested but the grammar backend do
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/ef58922c29b30d81.
Report an issue: GitHub.