Remove the dead `<tool_sep>` branch from chat_template.jinja (fixes OpenBMB/MiniCPM#379)

#19
by lhz7891444 - opened

Remove the dead <tool_sep> branch from chat_template.jinja (fixes OpenBMB/MiniCPM#379)

What

Two changes, nothing else:

  1. Delete the <tool_sep> handling block inside the assistant branch (former lines 54–117). It split content on <tool_sep> and tried to interleave the tool-call XML between the text segments by accumulating processed_content inside for loops.
  2. Change the trailing tool-call block guard from {%- if message.tool_calls and not has_tool_sep %} to {%- if message.tool_calls %}.

Diff: 66 lines removed, 1 line changed. Parameter rendering, reasoning handling, tool-response handling and the generation prompt are untouched.

Why

The branch never worked. Jinja2 does not propagate {% set %} assignments made inside a for loop to the enclosing scope, so processed_content kept its initial value content_parts[0] β€” everything after the first <tool_sep> was silently dropped (see #379 for the minimal reproducer). has_tool_sep was never defined anywhere, so the trailing guard was always true and the tool-call XML was emitted by the fallback block regardless.

The branch is unreachable in normal serving. <tool_sep> is not a special token in the tokenizer, the SGLang minicpm5_detector neither produces nor consumes it, and the model does not emit it (0/10 samples across prompts designed to elicit "text, then tool call, then text"). Only a hand-crafted assistant message containing the literal string <tool_sep> reaches this code, and in that case it loses data.

Removing it is therefore a pure cleanup with one observable effect: an assistant content that happens to contain <tool_sep> is now preserved verbatim instead of being truncated.

xcjthu changed pull request status to merged

Sign up or log in to comment