[Bugfix] [Parser] Fix empty tool block silently dropping subsequent content (#46091)

Signed-off-by: Ben Browning <bbrownin@redhat.com>
Co-authored-by: Flora Feng <4florafeng@gmail.com>
This commit is contained in:
Ben Browning
2026-06-18 23:17:18 +00:00
committed by GitHub
co-authored by Flora Feng
parent c3c6d723fd
commit 7f616c327d
4 changed files with 26 additions and 3 deletions
+1 -1
View File
@@ -672,7 +672,7 @@ class ParserEngine(Parser):
if len(tool_call_deltas) > 1:
tool_call_deltas = self._coalesce_tool_call_deltas(tool_call_deltas)
if self._deferred_content and not seen_tool_event:
if self._deferred_content and (not seen_tool_event or not tool_call_deltas):
content_parts.insert(0, self._deferred_content)
self._deferred_content = ""
+4
View File
@@ -375,6 +375,10 @@ def gemma4_config() -> ParserEngineConfig:
ParserState.TOOL_PREAMBLE,
(EventType.REASONING_END, EventType.TOOL_CALL_START),
),
(ParserState.TOOL_PREAMBLE, "TOOL_END"): Transition(
ParserState.CONTENT,
(EventType.TOOL_CALL_END,),
),
(ParserState.TOOL_PREAMBLE, "CALL_PREFIX"): Transition(
ParserState.TOOL_NAME,
(),
+4
View File
@@ -125,6 +125,10 @@ def qwen3_config(thinking: bool = True) -> ParserEngineConfig:
ParserState.TOOL_NAME,
(EventType.TOOL_CALL_START,),
),
(ParserState.TOOL_PREAMBLE, "TOOL_END"): Transition(
ParserState.CONTENT,
(EventType.TOOL_CALL_END,),
),
(ParserState.TOOL_PREAMBLE, "FUNC_PREFIX"): Transition(
ParserState.TOOL_NAME,
(),