Skip to content

Add GLM-4-MoE tool calling support#5463

Open
qgallouedec wants to merge 24 commits intomainfrom
glm4moe-tool-calling
Open

Add GLM-4-MoE tool calling support#5463
qgallouedec wants to merge 24 commits intomainfrom
glm4moe-tool-calling

Conversation

@qgallouedec
Copy link
Copy Markdown
Member

@qgallouedec qgallouedec commented Apr 6, 2026

  • Add response schema for GLM-4-MoE (<tool_call>name\n<arg_key>...<arg_value>... format) (done by Claude)
  • Add glm4moe.jinja template for identity matching in add_response_schema
  • Add GLM-4-MoE to TestAddResponseSchema and TestParseResponse test parametrizations
  • Add GLM-4-MoE to supported models in agent training docs

Part of #5460

Warning

Requires/contains #5459


Note

Medium Risk
Adds a new response-parsing regex/schema and chat-template identity match for GLM-4-MoE; incorrect regex or template mismatches could cause tool-call parsing failures or mis-parsed assistant content.

Overview
Adds GLM-4-MoE tool-calling support by introducing a new glm4moe.jinja identity template and wiring add_response_schema() to attach a GLM-4-MoE-specific response_schema that parses <tool_call>...<arg_key>...<arg_value>... formatted calls.

Extends the chat template utilities test suite to run add_response_schema/parse_response parametrizations against a GLM-4-MoE tiny model, and updates GRPO agent-training docs to list GLM-4-MoE as a tested/supported model.

Reviewed by Cursor Bugbot for commit 3fc2ca8. Bugbot is set up for automated code reviews on this repo. Configure here.

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@qgallouedec
Copy link
Copy Markdown
Member Author

cc @Rocketknight1 for the schema

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3fc2ca8. Configure here.

```
"""
if tokenizer.chat_template == glm4moe_chat_template:
tokenizer.response_schema = glm4moe_schema
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing return statement in GLM-4-MoE branch

High Severity

The glm4moe branch in add_response_schema sets the response_schema but is missing a return tokenizer statement. Execution falls through to the final ValueError, causing add_response_schema to always fail for GLM-4-MoE tokenizers. This breaks tool-calling support, for example, during GRPOTrainer initialization.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3fc2ca8. Configure here.

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.

3 participants