sgl-project/sglang · error · ValueError

Anthropic thinking is not supported for models without a rea

Error message

Anthropic thinking is not supported for models without a reasoning parser

What it means

An Anthropic-style request enabled thinking (enabled=True) but the served model has no reasoning parser configured, so the server cannot split/parse reasoning output. apply_reasoning_enabled raises to refuse producing unparsable thinking content.

Source

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

        if mode in ("thinking", "enable_thinking"):
            return mode
        if mode in ("explicit_thinking", "explicit_enable_thinking"):
            return mode.replace("explicit_", "")
        return None

    def apply_reasoning_enabled(
        self, request: ChatCompletionRequest, enabled: bool
    ) -> None:
        """Force the request into the requested reasoning-on/off mode.

        Mirrors the read-side logic in ``_get_reasoning_from_request``;
        the two must stay in sync. Always-on models cannot be disabled,
        so explicit ``enabled=False`` raises rather than silently leaving
        reasoning on.
        """
        if not self.reasoning_parser:
            if enabled:
                raise ValueError(
                    "Anthropic thinking is not supported for models without "
                    "a reasoning parser"
                )
            return

        if self.reasoning_parser == "hunyuan":
            request.reasoning_effort = "medium" if enabled else "no_think"
            return

        if self.reasoning_parser == "inkling":
            # Effort-conditioned, not toggled: "none" (0.0) is the off switch.
            if not enabled:
                request.reasoning_effort = "none"
                return

        config = self.template_manager.reasoning_config
        is_mistral = (config is not None and config.special_case == "mistral") or (
            config is None and self._reasoning_default_mode() == "mistral"

View on GitHub (pinned to 0132848349)

Solutions

  1. Launch server with the appropriate --reasoning-parser for a reasoning model
  2. Send thinking enabled=False (or omit it) for non-reasoning models
  3. Gate the thinking parameter in the client on model capability

Example fix

# before
request.thinking = {"type": "enabled", "budget_tokens": 1024}  # model w/o parser
# after
request.thinking = None
Defensive patterns

Strategy: validation

Validate before calling

if thinking_enabled and not server_has_reasoning_parser: thinking = None

Type guard

def can_enable_thinking(model_cfg) -> bool:
    return bool(model_cfg.get('reasoning_parser'))

Try / catch

except ValueError as e: if 'no reasoning parser' in str(e): retry without thinking

Prevention

When it happens

Trigger: Anthropic-compatible request with thinking={"type":"enabled",...} while the server lacks --reasoning-parser for the model.

Common situations: Porting an Anthropic client to a non-reasoning model; enabling thinking flags unconditionally in a client harness; forgetting server-side --reasoning-parser.

Related errors


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