Skip to content

[Bug] Tool-call-parser fails to format function calls for GLM5.1 (works for GLM5) in cursor #22922

Description

@MeowGrange

Checklist

  • I searched related issues but found no solution.
  • The bug persists in the latest version.
  • Issues without environment info and a minimal reproducible demo are hard to resolve and may receive no feedback.
  • If this is not a bug report but a general question, please start a discussion at https://github.com/sgl-project/sglang/discussions. Otherwise, it will be closed.
  • Please use English. Otherwise, it will be closed.

Describe the bug

When serving the GLM5.1 model , the tool calling / function calling feature does not work correctly through the OpenAI-compatible API.

The sglang server runs fine without any crash or error logs. However, when the model attempts to use a tool (e.g., generating a shell command), the tool-call-parser (presumably the glm47 template parser) fails to recognize and parse the model's output. As a result, the tool call is returned as plain text content rather than a proper tool_calls array in the JSON response.

By using the control variable method, I confirmed that serving the older GLM5 model with the exact same setup works perfectly, and tools are parsed and executed correctly by client applications (like Cursor IDE).

Expected behavior

The sglang tool-call-parser should be updated to support the slightly changed prompt/output format of GLM5.1, so that it can correctly parse the model's raw text into standard OpenAI tool_calls JSON structure.

Additional Context

Client application: Cursor IDE (Cursor fails to recognize the shell tool block when using GLM5.1 via sglang, but works fine with GLM5). Because there are no server-side error logs, it seems to be a pure parsing regex/logic mismatch in the chat template for the new model version.

Image

Reproduction

Server Startup Command:
python3 -m sglang.launch_server
--model-path /workdir/huggingface.co/zai-org/GLM-5.1-FP8
--host 0.0.0.0
--port 30000
--tp 8
--reasoning-parser glm45
--tool-call-parser glm47
--mem-fraction-static 0.85
How to reproduce:

  1. Start the server using the command above with a GLM5.1 model.
  2. Connect Cursor IDE to http://127.0.0.1:30000/v1 and try to use a Cursor Agent with shell tools.
  3. Observable behavior: In Cursor, the shell tool fails to execute normally. Instead of triggering the tool, the model just outputs the raw tool calling syntax as plain text in the chat. This indicates sglang fails to parse the GLM5.1 output into the standard tool_calls JSON format required by the client. (Note: Using the exact same setup with a GLM5 model works perfectly, and shell tools are executed normally in Cursor).

Environment

Python: 3.10.12
CUDA available: True
GPU 0,1,2,3,4,5,6,7: NVIDIA H20-3e
GPU 0,1,2,3,4,5,6,7 Compute Capability: 9.0
NVCC: Cuda compilation tools, release 12.6, V12.6.68
CUDA Driver Version: 550.127.08
PyTorch: 2.9.1+cu128
sglang: 0.5.10.post1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions