sgl-project/sglang · error · ValueError

unsupported Inkling message role {role!r}; expected one of {

Error message

unsupported Inkling message role {role!r}; expected one of {sorted(ROLE_MESSAGE_TOKENS)}

What it means

The Inkling renderer only accepts messages whose 'role' is a key in ROLE_MESSAGE_TOKENS (assistant/user/tool etc.). Any other role string raises ValueError listing the allowed roles.

Source

Thrown at python/sglang/srt/parser/inkling_renderer.py:264

        else:
            raise ValueError(f"unsupported content part type: {ptype!r}")


def _format_reasoning_effort(reasoning_effort: float) -> str:
    if isinstance(reasoning_effort, bool) or not isinstance(
        reasoning_effort, (int, float)
    ):
        raise TypeError("Inkling reasoning_effort must be a number")
    value = float(reasoning_effort)
    if not math.isfinite(value) or not 0.0 <= value <= 0.99:
        raise ValueError("Inkling reasoning_effort must be finite and in [0.0, 0.99]")
    return f"{round(value, 2):g}"


def _expect_role(message: Mapping[str, Any]) -> str:
    role = message.get("role")
    if role not in ROLE_MESSAGE_TOKENS:
        raise ValueError(
            f"unsupported Inkling message role {role!r}; expected one of {sorted(ROLE_MESSAGE_TOKENS)}"
        )
    return str(role)


def _as_mapping(value: Any) -> Mapping[str, Any]:
    if isinstance(value, Mapping):
        return value
    if hasattr(value, "model_dump"):
        dumped = value.model_dump()
        if isinstance(dumped, Mapping):
            return dumped
    raise TypeError(f"expected mapping, got {type(value).__name__}")


def _canonical_json(value: Any) -> str:
    return json.dumps(
        _sort_json(value),

View on GitHub (pinned to 0132848349)

Solutions

  1. Use only roles listed in the error message / ROLE_MESSAGE_TOKENS (typically user, assistant, tool)
  2. Fold system/developer instructions into the first user message or the dedicated system parameter

Example fix

# before
messages=[{"role":"developer","content":"be terse"}]
# after
messages=[{"role":"user","content":"(Instructions: be terse)\nHello"}]
Defensive patterns

Strategy: validation

Validate before calling

from sglang.srt.parser.inkling_renderer import ROLE_MESSAGE_TOKENS
assert all(m.get("role") in ROLE_MESSAGE_TOKENS for m in messages)

Type guard

def roles_ok(msgs, allowed): return all(m.get("role") in allowed for m in msgs)

Try / catch

try: render_inkling_messages(...)
except ValueError as e: if "unsupported Inkling message role" in str(e): merge unsupported-role content into the nearest user message

Prevention

When it happens

Trigger: Sending {"role":"system",...} if system is not in ROLE_MESSAGE_TOKENS for this model, or a role like "developer" or "function".

Common situations: Using newer OpenAI role names ('developer') or function-calling roles against an Inkling model whose template lacks them.

Related errors


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