Skip to content

Qwen3Renderer silently renders an empty turn when content is a list of text parts #134

Description

@vsimkus

Qwen3Renderer reads content only when it is already a str and coerces anything else to "", so a message built from OpenAI-style content parts renders as a well-formed but empty turn. Both call sites do it - qwen3.py:215 (render) and qwen3.py:398 (bridge_to_next_turn):

content = msg.get("content") if isinstance(msg.get("content"), str) else ""

Repro

from renderers import Qwen3Renderer
from transformers import AutoTokenizer

messages = [
    {"role": "user", "content": "What is 2+2?"},
    {"role": "assistant", "content": [{"type": "text", "text": "The answer is 4."}]},
]
tok = AutoTokenizer.from_pretrained("Qwen/Qwen3-30B-A3B")
print(repr(tok.decode(Qwen3Renderer(tok).render(messages).token_ids)))

The assistant's text is gone:

'<|im_start|>user\nWhat is 2+2?<|im_end|>\n<|im_start|>assistant\n<think>\n\n</think>\n\n<|im_end|>\n'

Llama3Renderer on the same messages keeps it: ...assistant<|end_header_id|>\n\nThe answer is 4.<|eot_id|>.

Proposed fix

Copy Llama3Renderer._content_str (llama_3.py:136), which already handles str / None / list-of-text-parts and raises on anything else, and replace both coercions with content = self._content_str(msg.get("content")).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions