[Bugfix] Handle bare and malformed tool call openers in Gemma4 parser (#53444)

Signed-off-by: wuhangxian <1391938827@qq.com>
Co-authored-by: Chauncey <chaunceyjiang@gmail.com>
This commit is contained in:
wuhangxian
2026-09-15 02:52:43 +00:00
committed by GitHub
co-authored by Chauncey
parent e45bb43984
commit a529c1a748
2 changed files with 116 additions and 0 deletions
+8
View File
@@ -303,6 +303,7 @@ def gemma4_config() -> ParserEngineConfig:
"TOOL_START": TOOL_CALL_START,
"TOOL_END": TOOL_CALL_END,
"CALL_PREFIX": "call:",
"COLON": ":",
"OPEN_BRACE": "{",
"OPEN_PAREN": "(",
},
@@ -348,6 +349,13 @@ def gemma4_config() -> ParserEngineConfig:
ParserState.TOOL_NAME,
(),
),
# Bare opener: some checkpoints emit "<|tool_call>:name{...}"
# without the "call" prefix. Match the colon directly so the
# tool call is not silently dropped.
(ParserState.TOOL_PREAMBLE, "COLON"): Transition(
ParserState.TOOL_NAME,
(),
),
(ParserState.TOOL_NAME, "OPEN_BRACE"): Transition(
ParserState.TOOL_ARGS,
(),