sgl-project/sglang · error · ValueError
reasoning_effort must not be a boolean
Error message
reasoning_effort must not be a boolean
What it means
Chat completion request validator explicitly rejects booleans for reasoning_effort (bool is a subclass of int in Python, so this guard runs before enum checks).
Source
Thrown at python/sglang/srt/entrypoints/openai/protocol.py:980
return _migrate_deprecated_dp_rank(values)
@model_validator(mode="before")
@classmethod
def set_tool_choice_default(cls, values):
if values.get("tool_choice") is None:
if values.get("tools") is None and not _has_message_level_tools(
values.get("messages")
):
values["tool_choice"] = "none"
else:
values["tool_choice"] = "auto"
return values
@field_validator("reasoning_effort", mode="before")
@classmethod
def validate_reasoning_effort_type(cls, value):
if isinstance(value, bool):
raise ValueError("reasoning_effort must not be a boolean")
return value
@model_validator(mode="before")
@classmethod
def normalize_reasoning_inputs(cls, values: Dict):
r = values.get("reasoning")
thinking = None
if r is not None and isinstance(r, dict):
effort = r.get("effort")
if effort is None:
effort = r.get("reasoning_effort")
if isinstance(effort, str) and effort in {
"none",
"minimal",
"low",
"medium",
"high",View on GitHub (pinned to 0132848349)
Solutions
- Set reasoning_effort to a valid string like 'low'/'medium'/'high' or omit it.
- Audit config templating so booleans never land in reasoning_effort.
Example fix
# before
{"reasoning_effort": true}
# after
{"reasoning_effort": "high"} Defensive patterns
Strategy: type-guard
Validate before calling
if reasoning_effort is not None:
assert not isinstance(reasoning_effort,bool) and isinstance(reasoning_effort,str) Type guard
def valid_effort(v): return v is None or (isinstance(v,str) and not isinstance(v,bool))
Prevention
- Never let config booleans flow into reasoning_effort.
- Default reasoning_effort to None or a string.
When it happens
Trigger: reasoning_effort=true/false or True/False in the request JSON.
Common situations: Config templating that substitutes booleans; YAML/JSON configs where effort level was toggled to a bool; dynamic kwargs passing unchecked flags.
Related errors
- 'role' must be a string
- Inkling reasoning_effort must be a number
- spt must be a bool when provided
- Unknown type: {type(other)}
- Invalid value: {other}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/7f5ca2fb44bbf2ac.
Report an issue: GitHub.