sgl-project/sglang · error · ValueError
Model type must be specified
Error message
Model type must be specified
What it means
Reasoning parser factory error: no model type was provided when looking up or constructing a reasoning parser. The parser selection is keyed by model_type (e.g. deepseek-r1, qwen3), so it must be specified explicitly via server args or model config.
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
- batch_draft_token_num config value
- consumer_count must be positive
- Either quant_config or online_scheme must be provided
- f"The class must implement the 'embedding' method, see…
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/2276c97911510073.
Report an issue: GitHub.
Appendix: 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)