{"record":{"id":"e7045efa360e483e","repo":"sgl-project/sglang","slug":"assistant-reasoning-content-must-be-a-string-for-i","errorCode":null,"errorMessage":"assistant reasoning_content must be a string for Inkling rendering","messagePattern":"assistant reasoning_content must be a string for Inkling rendering","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/parser/inkling_renderer.py","lineNumber":130,"sourceCode":"                if kind == \"thinking\":\n                    raise ValueError(\"Inkling thinking parts require role='assistant'\")\n                _append_message(\n                    input_ids,\n                    tokenizer,\n                    \"tool\",\n                    kind,\n                    text,\n                    author_name=tool_name,\n                )\n            continue\n\n        parts = list(_iter_render_parts(message.get(\"content\", \"\")))\n        turn_start = len(input_ids)\n        if role == \"assistant\":\n            reasoning_content = message.get(\"reasoning_content\")\n            if reasoning_content:\n                if not isinstance(reasoning_content, str):\n                    raise TypeError(\n                        \"assistant reasoning_content must be a string for Inkling rendering\"\n                    )\n                if any(kind == \"thinking\" for kind, _ in parts):\n                    raise ValueError(\n                        \"assistant message cannot mix reasoning_content with ordered thinking parts\"\n                    )\n                _append_message(\n                    input_ids,\n                    tokenizer,\n                    \"assistant\",\n                    \"thinking\",\n                    reasoning_content,\n                )\n\n        for kind, text in parts:\n            if kind == \"thinking\" and role != \"assistant\":\n                raise ValueError(\"Inkling thinking parts require role='assistant'\")\n            _append_message(input_ids, tokenizer, role, kind, text)","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/parser/inkling_renderer.py#L112-L148","documentation":"Inkling rendering supports assistant reasoning_content only as a string (typically produced by the model itself). If a truthy non-string value (dict, list, number) is passed, it raises TypeError.","triggerScenarios":"Passing message={\"role\":\"assistant\",\"reasoning_content\":[\"step1\"], ...} or reasoning_content={\"text\": \"...\"} to a chat request handled by the Inkling renderer.","commonSituations":"Clients that store reasoning as structured traces (lists of steps or JSON objects) and echo them back in multi-turn history.","solutions":["Serialize reasoning_content to a single string (e.g. json.dumps or '\\n'.join) before sending","Omit reasoning_content from replayed history if the template allows"],"exampleFix":"# before\nmsg[\"reasoning_content\"] = [\"step 1\", \"step 2\"]\n# after\nmsg[\"reasoning_content\"] = \"\\n\".join([\"step 1\", \"step 2\"])","handlingStrategy":"type-guard","validationCode":"for m in messages:\n    rc = m.get(\"reasoning_content\")\n    if rc is not None: assert isinstance(rc, str), type(rc)","typeGuard":"def reasoning_ok(m):\n    rc = m.get(\"reasoning_content\")\n    return rc is None or isinstance(rc, str)","tryCatchPattern":null,"preventionTips":["Serialize structured reasoning to one string before replay","Catch TypeError near the chat call to give a clearer message"],"tags":["inkling","reasoning","type-error"],"backgroundTag":"invalid-field-type","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}