sgl-project/sglang · error · ValueError

unsupported Inkling render part kind: {kind!r}

Error message

unsupported Inkling render part kind: {kind!r}

What it means

_append_message encodes each (role, kind, text) part; only specific kinds (text, thinking, image, audio, invoke_tool_json, etc.) are supported. An unrecognized kind — usually produced by a bug or a new part type not wired into the renderer — raises ValueError.

Source

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

        input_ids.extend(tokenizer.encode_text(text))
    elif kind == "image":
        input_ids.append(tokenizer.encode_special(CONTENT_IMAGE))
        input_ids.append(IMAGE_TOKEN_ID)
    elif kind == "audio":
        input_ids.append(tokenizer.encode_special(CONTENT_AUDIO_INPUT))
        input_ids.append(AUDIO_TOKEN_ID)
        input_ids.append(tokenizer.encode_special(AUDIO_END))
    elif kind == "thinking":
        input_ids.append(tokenizer.encode_special(CONTENT_THINKING))
        input_ids.extend(tokenizer.encode_text(text))
    elif kind == "xml":
        input_ids.append(tokenizer.encode_special(CONTENT_XML))
        input_ids.extend(tokenizer.encode_text(text))
    elif kind == "invoke_tool_json":
        input_ids.append(tokenizer.encode_special(CONTENT_INVOKE_TOOL_JSON))
        input_ids.extend(tokenizer.encode_text(text))
    else:
        raise ValueError(f"unsupported Inkling render part kind: {kind!r}")

    input_ids.append(tokenizer.encode_special(END_MESSAGE))


def _iter_render_parts(content: Any):
    """Yield ordered ``(kind, text)`` pairs from message content."""
    if content is None:
        return
    if isinstance(content, str):
        if content:
            yield ("text", content)
        return
    if not isinstance(content, Sequence) or isinstance(content, (bytes, bytearray)):
        raise TypeError("message content must be a string or a sequence of parts")
    for part in content:
        if isinstance(part, str):
            yield ("text", part)
            continue

View on GitHub (pinned to 0132848349)

Solutions

  1. Add an elif branch in _append_message for the new kind with the appropriate special tokens
  2. Verify every kind yielded by _iter_render_parts has a matching branch

Example fix

# before
yield ("video", "")
# ...no branch in _append_message
# after
elif kind == "video":
    input_ids.append(tokenizer.encode_special(CONTENT_VIDEO))
    input_ids.extend(tokenizer.encode_text(text))
Defensive patterns

Strategy: try-catch

Try / catch

try: render_inkling_messages(...)
except ValueError as e: if "unsupported Inkling render part kind" in str(e): fail fast with the part kind in the log

Prevention

When it happens

Trigger: Internal: extending _iter_render_parts to yield a new kind (e.g. 'video') without adding a branch in _append_message; externally reachable only if a content part type maps to an unhandled kind.

Common situations: Contributors adding a new multimodal part type to the Inkling renderer and forgetting the encoding branch.

Related errors


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