sunnyshechkaa commited on
Commit
6f339ec
·
verified ·
1 Parent(s): 707f0a3

Emit an empty thought after a tool response when enable_thinking=false

Browse files

Same change as https://huggingface.co/google/gemma-4-26B-A4B-it/discussions/67: this repository ships a byte-identical `chat_template.jinja`.

With `enable_thinking=false` the generation prompt after a user turn ends with an empty thought
(`<|channel>thought\n<channel|>`), but after a tool response it ends right after `<tool_response|>`. The model then
opens the thought channel on its own; on long tool-calling conversations it sometimes never closes it, and a
reasoning parser returns an empty `content`. This change emits the same empty thought after a tool response. The
renders after a user turn, and with `enable_thinking=true`, are unchanged.

Reproduction, measurements and a workaround are in the linked PR. They were made with gemma-4-26B-A4B-it; I did not
run this checkpoint.

Files changed (1) hide show
  1. chat_template.jinja +2 -0
chat_template.jinja CHANGED
@@ -386,5 +386,7 @@
386
  {%- endif -%}
387
  {%- elif ns.prev_message_type == 'tool_response' and enable_thinking -%}
388
  {{- '<|channel>thought\n' -}}
 
 
389
  {%- endif -%}
390
  {%- endif -%}
 
386
  {%- endif -%}
387
  {%- elif ns.prev_message_type == 'tool_response' and enable_thinking -%}
388
  {{- '<|channel>thought\n' -}}
389
+ {%- elif ns.prev_message_type == 'tool_response' -%}
390
+ {{- '<|channel>thought\n<channel|>' -}}
391
  {%- endif -%}
392
  {%- endif -%}