Fix chat template: render assistant tool_calls history

#19

Thanks for LFM2. The 24B's tool discipline measured impressively in our runs.

Defect: the shipped message loop renders content but never renders a past assistant turn's tool_calls. OpenAI-compatible clients replay history in that standard form, so the template emits an empty assistant turn and removes the model's action history.

The 24B is more robust than the 1.2B when history is missing. Its 4-step chains survive, but the tested 6-step chains lose steps 5 and 6. On the official Q4_K_M GGUF with temperature 0.1, top_k 50, and llama.cpp, the shipped template scored ordered 0/3 and exact 0/3 on those 6-step runs.

With this fix, the like-for-like 6-step runs scored ordered 3/3 and exact 3/3: six requested calls in order, nothing extra, with grounded and correct final answers. The combined seeded suite of three 4-step and three 6-step runs scored ordered 6/6 and exact 6/6 with no middleware. The route doctor's verdict also changed from a template-history failure to healthy.

Fix: port the LFM2.5-8B-A1B tool-call macros into this template's message loop while preserving the 24B template's multimodal handling. Everything outside the tool-call path remains byte-identical. The standalone regression test covers the defect, fixed rendering, tool-free byte equality, list-form multimodal content, null content, hostile values, and malformed call shapes.

The patch deliberately follows the current 8B-family argument formatting. Any family-wide string-escaping policy belongs in a separate discussion rather than a hidden 24B-only change.

GGUF users receive the fix through a re-converted GGUF or llama-server --jinja --chat-template-file <this file>, which is how we verified it live.

Happy to adjust anything to your conventions.

Evidence, wire excerpts, regression tests, and reproductions:
https://github.com/graphometer/droplet/tree/main/public/evidence

Disclosure: prepared with heavy AI assistance; every claim above comes from recorded runs that can be inspected. Not affiliated with, endorsed by, or connected to Liquid AI.

Cannot merge
This branch has merge conflicts in the following files:
  • chat_template.jinja

Sign up or log in to comment