Skip to content

common : add GLM-4.5 tool calling support #15186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dhandhalyabhavik
Copy link

  • Add COMMON_CHAT_FORMAT_GLM_4_5 format enum
  • Implement GLM-4.5 tool call parser for <tool_call><arg_key><arg_value> format
  • Add template detection based on <arg_key> and <arg_value> tags
  • Fix null content handling in message parsing and serialization
  • Ensure GLM-4.5 detection runs before Hermes to avoid misidentification

This enables tool calling functionality for GLM-4.5 models when using --jinja flag. The parser handles GLM-4.5's XML-like tool call format with key-value argument pairs.

Make sure to read the contributing guidelines before submitting a PR

Personally verified working on Cherry Studio windows app with function as option.

Unfortunately its not working with OpenAI API SDK because jinja requires dict parser but OpenAI requires jinja.

- Add COMMON_CHAT_FORMAT_GLM_4_5 format enum
- Implement GLM-4.5 tool call parser for <tool_call><arg_key><arg_value> format
- Add template detection based on <arg_key> and <arg_value> tags
- Fix null content handling in message parsing and serialization
- Ensure GLM-4.5 detection runs before Hermes to avoid misidentification

This enables tool calling functionality for GLM-4.5 models when using --jinja flag.
The parser handles GLM-4.5's XML-like tool call format with key-value argument pairs.
@ajunca
Copy link

ajunca commented Aug 9, 2025

I tried the PR, and it fixes tool calling on GLM 4.5 Air (unsloth version) getting called correctly.
Then though this other problem #15046 arise.

@dhandhalyabhavik
Copy link
Author

I tried the PR, and it fixes tool calling on GLM 4.5 Air (unsloth version) getting called correctly. Then though this other problem #15046 arise.

But its Qwen tool calling issue right? I think once other pending PRs are merged you should not see the issue.

@ajunca
Copy link

ajunca commented Aug 9, 2025

Yea, I don't think is related to this specific PR. But the problem is shared with this Qwen tool calling issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants