Chat template: render assistant turns without reasoning in low-thinking mode

#2

Fixes the multi-turn bug described in [IFM issue link] (upstream: inception42/Jais-3-7B discussion #N).

What changes

This PR changes only the branch of chat_template.jinja that handles an assistant message with no thinking field:

  • If all five thinking fields (think, think_fast, think_faster, reasoning_content, reasoning) are missing or null, the turn renders as <ifm|think_faster>\n</ifm|think_faster>{content}. That's the low-thinking mode the technical report (§5.2) says was used in training for turns without reasoning, and it's byte-identical to an explicit think_faster: "" turn.
  • Values of the wrong type (int, list, ...) still raise an error.
  • For MLX, this replaces the local "tolerate assistant history" patch. That patch rendered an empty high-effort <ifm|think> block and still raised on null.

Verification

I checked this with transformers 5.13.0:

Check Result
Content-only assistant turn, reasoning_content: null, all five fields null render, identical to think_faster: ""
reasoning_content: 123 / ["x"] still raise
12 conversations the shipped template accepts (high, medium and low effort; system prompt; each thinking field; tool call + tool response) 12/12 byte-identical
return_assistant_tokens_mask=True masks cover assistant turns only
Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment