Vibeleaderboard
← All Intel
Intel / post

GLM-5.1 tool-call loops traced to a chat template bug

Source
x.com
Publisher
Z.ai
Date
Z.ai@Zai_org

GLM-5.1 Tool Calling Issue Fix & Chat Template Update If you are running GLM-5.1 with vLLM/SGLang and using tool calling, please update your chat template. https://t.co/XyyCucws82 Issue When using tool calling, frameworks including vLLM automatically convert plain-text tool message content into an array of content parts (`[{"type": "text", "text": "..."}]`) before passing it to the chat template. The original template only supported string-formatted tool content, causing array-formatted tool outputs to render empty. As a result, the model does not receive tool results and repeatedly triggers the same tool call in a loop. Affected Models All GLM-5.1 variants deployed with vLLM or SGLang. Fix Simply replace your existing `chat_template.jinja` with the updated version from the repository.

Context

GLM-5.1 agents that kept repeating the same under vLLM or SGLang were never seeing the 's answer, and Z.ai traced that to the model's chat template. A chat template is the that turns a conversation's structured messages, including what a tool returns, into the text the model actually reads. According to Z.ai's April 16 notice, serving frameworks including vLLM convert a tool's plain-text reply into a list of content parts before passing it to the template. The original GLM-5.1 template only handled tool replies written as a single string, so a reply in list form rendered as empty text, the model received no result, and it issued the same call again in a loop.

Z.ai said every GLM-5.1 variant deployed with vLLM or SGLang is affected, and that the fix is to replace the deployment's chat_template.jinja with the updated file from the model repository. The template now on Hugging Face shows the repaired handling: a tool reply that is a string is wrapped as a tool response directly, and a reply in list form goes through a helper that pulls out the text of each part. Because the template is a file stored with the deployment, a set up with the old version keeps looping until someone swaps that file in.

Terms in this piece · Glossary
  • Tool call — Text the model generates in an agreed format that names a tool and gives its inputs.
  • Tool — An operation that the software around a model makes available for the model to request, with a name, expected inputs and a kind of result.
  • File — A named unit of stored data that keeps its contents while no program is using it.
  • Server — Software that receives requests, processes them and returns responses; the computer running it is its host.

Get the Brief

A cited digest of what matters for people building with AI, every morning. Unsubscribe anytime. See today’s edition

More from Z.ai
Recommended reads