sgl-project/sglang · error · ValueError
Model type must be specified
Error message
Model type must be specified
What it means
ReasoningParser.__init__ requires a non-empty model_type string; it uses it to select a detector class from DetectorMap and refuses to construct with a falsy value (empty string or None).
Source
Thrown at python/sglang/srt/parser/reasoning_parser.py:1972
"mistral": MistralDetector,
"nemotron_3": Nemotron3Detector,
"interns1": Qwen3Detector,
"gemma4": Gemma4Detector,
"inkling": InklingDetector,
"cohere_command4": CohereCommand4Detector,
}
def __init__(
self,
model_type: Optional[str] = None,
stream_reasoning: bool = True,
force_reasoning: Optional[bool] = None,
request: ChatCompletionRequest = None,
tokenizer=None,
tool_call_parser_active: bool = False,
):
if not model_type:
raise ValueError("Model type must be specified")
detector_class = self.DetectorMap.get(model_type.lower())
if not detector_class:
raise ValueError(f"Unsupported model type: {model_type}")
chat_template_kwargs = getattr(request, "chat_template_kwargs", None) or {}
# Special cases where we override force_reasoning
if model_type.lower() in {
"qwen3-thinking",
"gpt-oss",
"minimax",
}:
force_reasoning = True
# M3 consumes the <mm:think> start tag only for thinking_mode=enabled
# (absent from output → must force); mirror serving_chat's M3 branch.
if model_type.lower() == "minimax-m3" and force_reasoning is None:View on GitHub (pinned to 0132848349)
Solutions
- Pass a concrete model type such as 'deepseek-r1', 'qwen3-thinking', etc.
- Trace where the empty model_type originated (server args / model config) and fix that wiring
- If constructing manually, default to a known parser name
Example fix
// before parser = ReasoningParser(model_type=model_type) # model_type is None // after parser = ReasoningParser(model_type=model_type or "deepseek-r1")
Defensive patterns
Strategy: validation
Validate before calling
if not model_type:
raise ValueError("model_type must be provided (check --reasoning-parser wiring)")
parser = ReasoningParser(model_type=model_type) Type guard
def has_model_type(mt: Any) -> TypeGuard[str]:
return isinstance(mt, str) and bool(mt.strip()) Try / catch
try:
parser = ReasoningParser(model_type=model_type)
except ValueError as e:
if "must be specified" in str(e):
fix_model_type_source() # e.g. default from server args
else:
raise Prevention
- Default model_type from a known config value at startup
- Fail fast on empty parser names in server-args validation
- Log the resolved model_type before parser construction
When it happens
Trigger: Constructing ReasoningParser(model_type='') or ReasoningParser(model_type=None), often because --reasoning-parser was set on the server but the per-request model type resolved empty.
Common situations: Server args wiring where model_type comes from a config lookup that returned None, or programmatic parser construction without a model name.
Related errors
- Unsupported model type: {model_type}
- Multiple serve backends matched this request: {names}. Selec
- f"Unknown feature map: {feature_map}"
- n_q/n_k must be one of {VALID_N}, got n_q={n_q}, n_k={n_k}
- f"Unsupported patch_size type: {type(patch_size)}"
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/2276c97911510073.
Report an issue: GitHub.