lucianommartins commited on
Commit
1f435d2
·
verified ·
1 Parent(s): 3856feb

fix: prevent extra <turn|> when assistant has content + tool_calls + continuation

Browse files

The continues_into_next condition blocked continuation when the
assistant message had tool_calls (via 'not message.get(tool_calls)').
When tool responses were already rendered inline (ns_tr_out.flag),
the tool exchange is complete and the turn should continue — but
the condition forced a <turn|> close, producing an extra turn-end
marker between the first assistant's content and the continuation.

Fix: change the condition to allow continuation when tool responses
are present: (not tool_calls or ns_tr_out.flag).

Reported in https://github.com/vllm-project/vllm/pull/42776

Files changed (1) hide show
  1. chat_template.jinja +1 -2
chat_template.jinja CHANGED
@@ -359,8 +359,7 @@
359
  {%- set continues_into_next = (
360
  role == 'model'
361
  and next_nt.role == 'assistant'
362
- and not message.get('tool_calls')
363
- and not ns_tr_out.flag
364
  ) -%}
365
 
366
  {%- if ns.prev_message_type == 'tool_call' and not ns_tr_out.flag -%}
 
359
  {%- set continues_into_next = (
360
  role == 'model'
361
  and next_nt.role == 'assistant'
362
+ and (not message.get('tool_calls') or ns_tr_out.flag)
 
363
  ) -%}
364
 
365
  {%- if ns.prev_message_type == 'tool_call' and not ns_tr_out.flag -%}