lucianommartins commited on
Commit
77a7d3b
·
verified ·
1 Parent(s): 0cc2d28

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
@@ -356,8 +356,7 @@
356
  {%- set continues_into_next = (
357
  role == 'model'
358
  and next_nt.role == 'assistant'
359
- and not message.get('tool_calls')
360
- and not ns_tr_out.flag
361
  ) -%}
362
 
363
  {%- if ns.prev_message_type == 'tool_call' and not ns_tr_out.flag -%}
 
356
  {%- set continues_into_next = (
357
  role == 'model'
358
  and next_nt.role == 'assistant'
359
+ and (not message.get('tool_calls') or ns_tr_out.flag)
 
360
  ) -%}
361
 
362
  {%- if ns.prev_message_type == 'tool_call' and not ns_tr_out.flag -%}