Skip to content

Add GLM-4-MoE tool calling support#5463

Merged
qgallouedec merged 27 commits into
mainfrom
glm4moe-tool-calling
Apr 10, 2026
Merged

Add GLM-4-MoE tool calling support#5463
qgallouedec merged 27 commits into
mainfrom
glm4moe-tool-calling

Conversation

@qgallouedec

@qgallouedec qgallouedec commented Apr 6, 2026

Copy link
Copy Markdown
Member
  • 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 new response-parsing regex/schema and chat-template matching for GLM-4-MoE; incorrect regex/template identity matching could break tool-call parsing for affected tokenizers. Test coverage is added, but behavior depends on exact template text matching.

Overview
Adds GLM-4-MoE tool-calling response parsing by introducing a glm4moe_schema (including <tool_call>...<arg_key>/<arg_value> argument extraction) and wiring it into add_response_schema via exact match against a new glm4moe.jinja template.

Extends the test suite to run add_response_schema and parse_response 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 dba573c. 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

Comment thread docs/source/grpo_trainer.md Outdated
Comment thread trl/chat_template_utils.py Outdated
Comment thread tests/test_chat_template_utils.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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.

Comment thread trl/chat_template_utils.py
@qgallouedec qgallouedec merged commit 9c8e191 into main Apr 10, 2026
12 of 13 checks passed
@qgallouedec qgallouedec deleted the glm4moe-tool-calling branch April 10, 2026 19:22
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