sgl-project/sglang · error · ValueError

Inkling reasoning_effort must not be a boolean

Error message

Inkling reasoning_effort must not be a boolean

What it means

_parse_inkling_reasoning_effort rejects boolean reasoning_effort values for Inkling (GLM-style hybrid) models, which map effort to a float in [0, 0.99]. In Python bool is a subclass of int, so the check runs before numeric conversion to avoid True -> 1.0 silently failing the range check.

Source

Thrown at python/sglang/srt/entrypoints/openai/serving_chat.py:646

        if (
            last.get("role") != "assistant"
            or not isinstance(last.get("content"), str)
            or last.get("tool_calls")
            or last.get("reasoning_content")
        ):
            return None
        messages.pop()
        return last["content"]

    @staticmethod
    def _parse_inkling_reasoning_effort(
        value: Optional[Union[str, float]],
    ) -> Optional[float]:
        """Convert an OpenAI-style reasoning_effort to an Inkling float."""
        if value is None:
            return None
        if isinstance(value, bool):
            raise ValueError("Inkling reasoning_effort must not be a boolean")
        if isinstance(value, (int, float)):
            parsed = float(value)
            if not math.isfinite(parsed) or not 0.0 <= parsed <= 0.99:
                raise ValueError("Inkling reasoning_effort must be in [0.0, 0.99]")
            return parsed
        _EFFORT_MAP = {
            "none": 0.0,
            "minimal": 0.1,
            "low": 0.2,
            "medium": 0.7,
            "high": 0.9,
            "xhigh": 0.99,
            "max": 0.99,
        }
        if value in _EFFORT_MAP:
            return _EFFORT_MAP[value]
        try:
            parsed = float(value)

View on GitHub (pinned to 0132848349)

Solutions

  1. Pass a number 0.0-0.99 or a recognized label string ('none','low','medium','high',...)
  2. To disable reasoning use the appropriate enable/disable flag, not effort=false

Example fix

// before
{"reasoning_effort": true}
// after
{"reasoning_effort": 0.9}
Defensive patterns

Strategy: type-guard

Validate before calling

assert not isinstance(effort, bool), 'effort must not be boolean'

Type guard

def is_valid_inkling_effort(v):
    return v is None or (not isinstance(v, bool) and (isinstance(v, (int, float)) or isinstance(v, str)))

Prevention

When it happens

Trigger: Chat completion against an Inkling model with reasoning_effort=true/false, or chat_template_kwargs.reasoning_effort set to a boolean.

Common situations: Config systems encoding 'on'/'off' as booleans; clients that treat effort as a toggle; templated request bodies substituting booleans.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/bbcc94c832050fbc. Report an issue: GitHub.