{"record":{"id":"2583505ca1bf2d44","repo":"sgl-project/sglang","slug":"unsupported-inkling-message-role-role-r-expecte","errorCode":null,"errorMessage":"unsupported Inkling message role {role!r}; expected one of {sorted(ROLE_MESSAGE_TOKENS)}","messagePattern":"unsupported Inkling message role (.+?); expected one of (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/parser/inkling_renderer.py","lineNumber":264,"sourceCode":"        else:\n            raise ValueError(f\"unsupported content part type: {ptype!r}\")\n\n\ndef _format_reasoning_effort(reasoning_effort: float) -> str:\n    if isinstance(reasoning_effort, bool) or not isinstance(\n        reasoning_effort, (int, float)\n    ):\n        raise TypeError(\"Inkling reasoning_effort must be a number\")\n    value = float(reasoning_effort)\n    if not math.isfinite(value) or not 0.0 <= value <= 0.99:\n        raise ValueError(\"Inkling reasoning_effort must be finite and in [0.0, 0.99]\")\n    return f\"{round(value, 2):g}\"\n\n\ndef _expect_role(message: Mapping[str, Any]) -> str:\n    role = message.get(\"role\")\n    if role not in ROLE_MESSAGE_TOKENS:\n        raise ValueError(\n            f\"unsupported Inkling message role {role!r}; expected one of {sorted(ROLE_MESSAGE_TOKENS)}\"\n        )\n    return str(role)\n\n\ndef _as_mapping(value: Any) -> Mapping[str, Any]:\n    if isinstance(value, Mapping):\n        return value\n    if hasattr(value, \"model_dump\"):\n        dumped = value.model_dump()\n        if isinstance(dumped, Mapping):\n            return dumped\n    raise TypeError(f\"expected mapping, got {type(value).__name__}\")\n\n\ndef _canonical_json(value: Any) -> str:\n    return json.dumps(\n        _sort_json(value),","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/parser/inkling_renderer.py#L246-L282","documentation":"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.","triggerScenarios":"Sending {\"role\":\"system\",...} if system is not in ROLE_MESSAGE_TOKENS for this model, or a role like \"developer\" or \"function\".","commonSituations":"Using newer OpenAI role names ('developer') or function-calling roles against an Inkling model whose template lacks them.","solutions":["Use only roles listed in the error message / ROLE_MESSAGE_TOKENS (typically user, assistant, tool)","Fold system/developer instructions into the first user message or the dedicated system parameter"],"exampleFix":"# before\nmessages=[{\"role\":\"developer\",\"content\":\"be terse\"}]\n# after\nmessages=[{\"role\":\"user\",\"content\":\"(Instructions: be terse)\\nHello\"}]","handlingStrategy":"validation","validationCode":"from sglang.srt.parser.inkling_renderer import ROLE_MESSAGE_TOKENS\nassert all(m.get(\"role\") in ROLE_MESSAGE_TOKENS for m in messages)","typeGuard":"def roles_ok(msgs, allowed): return all(m.get(\"role\") in allowed for m in msgs)","tryCatchPattern":"try: render_inkling_messages(...)\nexcept ValueError as e: if \"unsupported Inkling message role\" in str(e): merge unsupported-role content into the nearest user message","preventionTips":["Restrict roles to user/assistant/tool for Inkling models","Fold system/developer text into the user turn"],"tags":["inkling","role-validation"],"backgroundTag":"unsupported-role","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}