{"record":{"id":"0101cb68381907f3","repo":"vllm-project/vllm","slug":"reasoningconfig-failed-to-tokenize-reasoning-stri","errorCode":null,"errorMessage":"ReasoningConfig: failed to tokenize reasoning strings: reasoning_start_str='{self.reasoning_start_str}', reasoning_end_str='{self.reasoning_end_str}'. Ensure the strings are valid tokens in the model's vocabulary.","messagePattern":"ReasoningConfig: failed to tokenize reasoning strings: reasoning_start_str='(.+?)', reasoning_end_str='(.+?)'\\. Ensure the strings are valid tokens in the model's vocabulary\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"vllm/config/reasoning.py","lineNumber":119,"sourceCode":"            # If we don't have valid strings to tokenize,\n            # we can't initialize the token IDs.\n            return\n        self._reasoning_start_token_ids = tokenizer.encode(\n            reasoning_start_str, add_special_tokens=False\n        )\n        self._reasoning_end_token_ids = tokenizer.encode(\n            reasoning_end_str, add_special_tokens=False\n        )\n        self._natural_reasoning_end_token_ids = tokenizer.encode(\n            natural_reasoning_end_str, add_special_tokens=False\n        )\n\n        if (\n            not self._reasoning_start_token_ids\n            or not self._reasoning_end_token_ids\n            or not self._natural_reasoning_end_token_ids\n        ):\n            raise ValueError(\n                f\"ReasoningConfig: failed to tokenize reasoning strings: \"\n                f\"reasoning_start_str='{self.reasoning_start_str}', \"\n                f\"reasoning_end_str='{self.reasoning_end_str}'. \"\n                \"Ensure the strings are valid tokens in the model's vocabulary.\"\n            )\n        self._enabled = True\n","sourceCodeStart":101,"sourceCodeEnd":126,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/config/reasoning.py#L101-L126","documentation":"ReasoningConfig encodes reasoning_start_str / reasoning_end_str with the model tokenizer; if any of the start, end, or natural-end strings tokenizes to an empty token-id list, the config is invalid and reasoning parsing stays disabled. The tokenizer simply does not recognize the string as one or more standalone tokens, so the parser could never match it reliably.","triggerScenarios":"Setting reasoning_start_str='[think]' when the tokenizer splits it into nothing matching (rare) or returns no ids; using special-token strings without the tokenizer that defines them; wrong tokenizer for the model; empty/whitespace strings after config templating.","commonSituations":"Using DeepSeek-R1 style '</think>' markers with a base tokenizer that lacks them; pointing --tokenizer at a different vocab than --model; YAML stripping or HTML-escaping the marker string; version change in default natural_reasoning_end_str handling.","solutions":["Verify the marker with tokenizer.encode(marker, add_special_tokens=False) and confirm a non-empty id list before starting vLLM","Use the exact token spelling from the model's tokenizer_config.json (e.g. '</think>' including of angle brackets)","Align --tokenizer with the checkpoint that defines the reasoning special tokens","If markers genuinely aren't in the vocab, disable ReasoningConfig and parse reasoning another way"],"exampleFix":"# before\nReasoningConfig(model='deepseek-ai/DeepSeek-R1', tokenizer=wrong_tok, reasoning_start_str='<think>', reasoning_end_str='</think>')\n\n# after\nReasoningConfig(model='deepseek-ai/DeepSeek-R1', tokenizer=r1_tok, reasoning_start_str='<think>', reasoning_end_str='</think>')  # r1_tok.encode('</think>') -> [151649]","handlingStrategy":"validation","validationCode":"def reasoning_markers_tokenize(tokenizer, start: str, end: str, natural_end: str) -> bool:\n    enc = lambda s: bool(tokenizer.encode(s, add_special_tokens=False))\n    return enc(start) and enc(end) and enc(natural_end)\n\nassert reasoning_markers_tokenize(tok, '<think>', '</think>', '</think>')","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Pre-encode markers with the model's own tokenizer before launch","Ship marker strings via the same config as --tokenizer","Unit-test marker tokenization in CI for each served model"],"tags":["reasoning","tokenizer","config","validation"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}