feat: Gemma 4 tool call + reasoning parser#250
Closed
Thump604 wants to merge 2 commits intowaybarrios:mainfrom
Closed
feat: Gemma 4 tool call + reasoning parser#250Thump604 wants to merge 2 commits intowaybarrios:mainfrom
Thump604 wants to merge 2 commits intowaybarrios:mainfrom
Conversation
Tool parser handles Gemma 4's native format:
<|tool_call>call:function_name{key:<|"|>value<|"|>}<tool_call|>
Parses <|"|>-escaped strings, numeric values, booleans.
Arguments serialized to JSON string for OpenAI API compat.
Reasoning parser handles channel-based thinking:
<|channel>thought\n...reasoning...<channel|>
Final answer content
Registered as "gemma4" in both parser registries.
CLI choices updated.
Tested: tool_calls extracted to API field, reasoning_content
separated from content, streaming works, concurrent batching works.
5 tasks
Gajesh2007
added a commit
to Gajesh2007/vllm-mlx
that referenced
this pull request
Apr 7, 2026
Port from upstream PRs waybarrios#250 and waybarrios#254: - gemma4_parser.py: extracts <|channel>thought...<channel|> into reasoning_content - gemma4_tool_parser.py: parses <|tool_call>call:name{...}<tool_call|> format - Auto-detection in AutoToolParser for Gemma 4 markers - Tests for tool parser
This was referenced Apr 7, 2026
Collaborator
Author
|
Quick merge signal on this one: this is the Gemma 4 parser pair we are already relying on locally on the current Gemma lane ( If you're doing a fast sweep, this one looks ready. |
Collaborator
|
+1 for merge — we've been running this in production on Gemma 4 26B-A4B (mixed 6/8-bit) for several days now with Clean implementation, no issues encountered. Would be great to get this into main. 🙏 |
3 tasks
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
<|tool_call>call:name{params}<tool_call|>with<|"|>string escaping<|channel>thought...<channel|>blocks intoreasoning_content--tool-call-parser gemma4and--reasoning-parser gemma4Addresses the server-side equivalent of ml-explore/mlx-lm#1096 (Gemma 4 native tool calls not parsed).
Details
Tool parser (
tool_parsers/gemma4_tool_parser.py):<|tool_call>call:name{...}<tool_call|><|"|>escaped string values, numeric/boolean coercionReasoning parser (
reasoning/gemma4_parser.py):<|channel>thought\n...reasoning...<channel|>from final answer(reasoning, content)tupleTest plan
tool_callsfield populated with correct function name + JSON argumentsreasoning_contentseparated fromcontent, both present