{"record":{"id":"ef58922c29b30d81","repo":"sgl-project/sglang","slug":"enable-strict-thinking-requires-a-grammar-backen-ef5892","errorCode":null,"errorMessage":"--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.","messagePattern":"--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\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"python/sglang/srt/constrained/base_grammar_backend.py","lineNumber":417,"sourceCode":"                f\"Grammar backend disabled because tokenizer is not supported by XGrammar: {e}. \"\n                \"Falling back to grammar_backend='none'. \"\n                \"Structured outputs (JSON schema, regex, EBNF) will not be available.\"\n            )\n            get_context().override(\"grammar.import_fallback\", grammar_backend=\"none\")\n            return None\n    elif name == \"llguidance\":\n        from sglang.srt.constrained.llguidance_backend import GuidanceBackend\n\n        grammar_backend = GuidanceBackend(\n            tokenizer=tokenizer,\n            any_whitespace=not get_serving().constrained_json_disable_any_whitespace,\n            whitespace_pattern=get_serving().constrained_json_whitespace_pattern,\n            n_vocab=vocab_size,\n            eos_token_ids=eos_token_ids,\n        )\n    elif name == \"none\":\n        if get_serving().enable_strict_thinking:\n            raise ValueError(\n                \"--enable-strict-thinking requires a grammar backend that supports \"\n                \"token filtering, but grammar_backend='none' was specified. Use \"\n                \"--grammar-backend xgrammar or another backend that supports token \"\n                \"filtering.\"\n            )\n        return None\n    else:\n        raise ValueError(f\"Invalid grammar backend: {name}\")\n\n    if get_serving().reasoning_parser and think_end_ids:\n        from sglang.srt.constrained.reasoner_grammar_backend import (\n            ReasonerGrammarBackend,\n        )\n\n        reasoning_parser = ReasoningParser(\n            model_type=get_serving().reasoning_parser,\n            stream_reasoning=False,\n            tokenizer=tokenizer,","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/constrained/base_grammar_backend.py#L399-L435","documentation":"--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.","triggerScenarios":"Passing both --grammar-backend none and --enable-strict-thinking on the server command line or ServerArgs.","commonSituations":"Users disabling the grammar backend to save startup time or avoid xgrammar issues, while separately enabling strict thinking; contradictory flags copied from different runbooks.","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"],"exampleFix":"# before\n--grammar-backend none --enable-strict-thinking\n# after\n--grammar-backend xgrammar --enable-strict-thinking","handlingStrategy":"validation","validationCode":"if server_args.grammar_backend == 'none':\n    assert not server_args.enable_strict_thinking, 'strict thinking requires a token-filtering grammar backend'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize flag-compatibility checks in a validate_server_args step","Document flag matrix; grep launch scripts for both flags before deploying"],"tags":["grammar","configuration","strict-thinking","startup"],"backgroundTag":"conflicting-configuration-flags","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}