Repository navigation
fix: parse GLM's <arg_key>/<arg_value> tool calls in both servers - #35
Closed
jeidbugs404 wants to merge 1 commit into
Closed
jeidbugs404 wants to merge 1 commit into
jeidbugs404 wants to merge 1 commit into
Conversation
GLM-4.5 and later (GLM-5.3-Flash among them) write a tool call as the function name followed by <arg_key>/<arg_value> pairs. The CUDA server left such a call in the reply as text and the HTTP server raised 'unsupported tool_call payload format'. Both now read it after their existing JSON and Qwen attempts, typing values by the offered tool's schema.
Owner
|
Thanks @jeidbugs404 for the GLM tool-call fix. It's integrated with the GLM Mac work, with one parser in both servers, and moves with it to 0.3.5.1 in the next few days. The PR stays open until then, and you'll be credited as the author when it lands. |
This was referenced Sep 28, 2026
Closed
ashhart
pushed a commit
that referenced
this pull request
Sep 28, 2026
Pull request #35 by jeidbugs404. GLM-4.5 and later (GLM-5.3-Flash among them) write a tool call as the function name followed by <arg_key>/<arg_value> pairs. The CUDA server left such a call in the reply as text and the HTTP server raised 'unsupported tool_call payload format'. Both now read it after their existing JSON and Qwen attempts, typing values by the offered tool's schema (parse_glm_tool_call_block), with 17 test cases through both parsers. Adapted by the maintainer to land on the 0.3.5 line: - The HTTP hunk moved from server/http.py to server/tools.py, where 0.3.5 keeps the parser, and the CUDA server imports the parser from there. - The tests sit in tests/test_glm_tool_calls_servers.py beside the existing GLM tool-call tests, importing from server/tools.py. - One case, test_qwen_function_blocks_are_unchanged[http-server], expects Qwen parameter values as text; since 0.3.5 the Mac server types them by the tool's schema. That expectation, and the one GLM implementation both servers share, follow in the next commit.
Owner
|
Your parser shipped in 0.3.6 (4fb2528, under your name). Both servers now read GLM's |
This was referenced Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GLM-4.5 and later, including GLM-5.3-Flash (the
glm5_nextrecipe), write a tool call as the function name followed by key/value pairs:That is the format the checkpoint's own
chat_template.jinjaasks for and writes back into the history (a string value as itself, any other value withtojson). Neither server reads it today:cuda/server.py,parse_tool_calls) reads Qwen<function=…><parameter=…>or JSON bodies only, so a GLM call stays in the reply as text: the client getsfinish_reason: "stop"and notool_calls. On v0.3.4.1 with the GLM-5.3-Flash EXL3 checkpoint on two DGX Sparks, 5 of 5 tool-call requests came back that way.server/http.py,parse_tool_calls_from_content) raisesunsupported tool_call payload formatfor the same block.Change
server/http.pygetsparse_glm_tool_call_block(block, tools). Both parsers call it only after their existing JSON and Qwen attempts fail, so those formats keep precedence and behave as before.tojson. If it doesn't parse, it stays text.Tests
tests/test_glm_tool_calls.pyruns 17 cases through both parsers:<function=…>and JSON bodies, unchanged.11 of the cases fail on
mainand all 17 pass here.pytest --ignore=tests/cudaon Linux without MLX or torch gives 146 passed and 28 skipped. The 4 failures and 2 collection errors are identical onmain, since they need MLX or torch.ruff checkreports nothing new on the changed files.Prepared with AI coding assistants. The fix and the test results above were produced and checked locally as described.