feat: add Gemma 4 tool call and reasoning parsers#274
Closed
mikepixelmagic-dev wants to merge 1 commit intowaybarrios:mainfrom
Closed
feat: add Gemma 4 tool call and reasoning parsers#274mikepixelmagic-dev wants to merge 1 commit intowaybarrios:mainfrom
mikepixelmagic-dev wants to merge 1 commit intowaybarrios:mainfrom
Conversation
Adds native support for Gemma 4's unique token format:
Tool calling:
- Parses <|tool_call>call:func_name{key:<|"|>value<|"|>}<tool_call|>
- Supports hyphenated/dotted function names (e.g. searxng-search)
- Streaming support with multi-token tag handling
Reasoning:
- Extracts <|channel>thought...<channel|> into reasoning_content field
- Stateful streaming parser handles tags that span multiple MLX tokens
- Works with both explicit and implicit thinking modes
Usage:
vllm-mlx serve mlx-community/gemma-4-26b-a4b-it-4bit \
--enable-auto-tool-choice \
--tool-call-parser gemma4 \
--reasoning-parser gemma4
Tested on Apple M5 Max with Gemma 4 26B-A4B (4-bit MLX).
Fixes waybarrios#264
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Owner
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.
Summary
Adds native Gemma 4 support for both tool calling and reasoning extraction.
--tool-call-parser gemma4): Parses Gemma 4's<|tool_call>call:func{key:<|"|>value<|"|>}<tool_call|>format. Supports hyphenated/dotted function names (e.g.searxng-search).--reasoning-parser gemma4): Extracts<|channel>thought...<channel|>tags into thereasoning_contentAPI field. Stateful streaming parser handles tags that span multiple MLX tokens.Usage
Files changed
vllm_mlx/tool_parsers/gemma4_tool_parser.pyvllm_mlx/tool_parsers/__init__.pyvllm_mlx/reasoning/gemma4_parser.pyvllm_mlx/reasoning/__init__.pyTest plan
searxng-search)reasoning_contentpopulated,contentclean)<|channel>tag leakage)mlx-community/gemma-4-26b-a4b-it-4bitFixes #264
🤖 Generated with Claude Code