sgl-project/sglang · error · ValueError

thinking.display is not allowed when thinking.type is 'disab

Error message

thinking.display is not allowed when thinking.type is 'disabled'

What it means

Raised by the Anthropic-compatible endpoint's validator when thinking.type='disabled' but a thinking.display field is present. Display configuration only applies to enabled thinking, so mixing it with 'disabled' is rejected as a 400.

Source

Thrown at python/sglang/srt/entrypoints/anthropic/protocol.py:302

        if self.type == "enabled":
            if self.budget_tokens is None:
                raise ValueError(
                    "thinking.budget_tokens is required when "
                    "thinking.type is 'enabled'"
                )
            if self.budget_tokens < 1024:
                raise ValueError(
                    "thinking.budget_tokens must be >= 1024 "
                    "(got {})".format(self.budget_tokens)
                )
        elif self.type == "disabled":
            if self.budget_tokens is not None:
                raise ValueError(
                    "thinking.budget_tokens is not allowed when "
                    "thinking.type is 'disabled'"
                )
            if self.display is not None:
                raise ValueError(
                    "thinking.display is not allowed when "
                    "thinking.type is 'disabled'"
                )
        elif self.type == "adaptive":
            if self.budget_tokens is not None:
                raise ValueError(
                    "thinking.budget_tokens is not allowed when "
                    "thinking.type is 'adaptive'"
                )
        return self


class AnthropicTaskBudget(BaseModel):
    """Claude 4.7 ``output_config.task_budget`` — soft hint, not a hard cap.

    Mirrors ``BetaTokenTaskBudgetParam`` in the Anthropic SDK: ``total``
    and ``type`` are required; ``remaining`` is the client-tracked
    countdown used for compaction. The hard cap on generation is still

View on GitHub (pinned to 0132848349)

Solutions

  1. Remove the display field when thinking.type is 'disabled'
  2. Set display to null/None
  3. Keep thinking only as {"type": "disabled"} when disabling

Example fix

// before
{"thinking": {"type": "disabled", "display": true}}
// after
{"thinking": {"type": "disabled"}}
Defensive patterns

Strategy: validation

Validate before calling

if thinking["type"] == "disabled":
    thinking = {"type": "disabled"}

Prevention

When it happens

Trigger: POST /v1/messages with {"thinking": {"type": "disabled", "display": true}} (or any non-null display value).

Common situations: Reusing a full thinking config dict and only flipping type to 'disabled'; SDK defaults that populate display; migrating configs between API versions where display was newly added.

Related errors


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