Fix chat_template: emit empty <|channel>thought\n<channel|> wrapper for existing asst turns

#78
Files changed (1) hide show
  1. chat_template.jinja +7 -0
chat_template.jinja CHANGED
@@ -232,6 +232,13 @@
232
  {{- '<|turn>' + role + '\n' }}
233
  {%- endif -%}
234
 
 
 
 
 
 
 
 
235
  {#- Render reasoning/reasoning_content as thinking channel -#}
236
  {%- set thinking_text = message.get('reasoning') or message.get('reasoning_content') -%}
237
  {%- if thinking_text and loop.index0 > ns_turn.last_user_idx and message.get('tool_calls') -%}
 
232
  {{- '<|turn>' + role + '\n' }}
233
  {%- endif -%}
234
 
235
+ {#- Non-thinking format: emit empty thought channel wrapper so that rendering an
236
+ existing assistant turn matches the training-time format produced by the
237
+ `add_generation_prompt=True` branch below. -#}
238
+ {%- if role == 'model' and not continue_same_model_turn and not thinking_text and not (enable_thinking | default(false)) -%}
239
+ {{- '<|channel>thought\n<channel|>' -}}
240
+ {%- endif -%}
241
+
242
  {#- Render reasoning/reasoning_content as thinking channel -#}
243
  {%- set thinking_text = message.get('reasoning') or message.get('reasoning_content') -%}
244
  {%- if thinking_text and loop.index0 > ns_turn.last_user_idx and message.get('tool_calls') -%}