[Bugfix] Parse DSML tool calls when the model omits the tool_calls wrapper (#55954)

Signed-off-by: sfeng33 <4florafeng@gmail.com>
This commit is contained in:
Flora Feng
2026-09-08 17:38:04 -07:00
committed by GitHub
parent 28a73ccfba
commit d98c8c030b
5 changed files with 232 additions and 8 deletions
+12 -2
View File
@@ -75,6 +75,10 @@ def deepseek_v32_config() -> ParserEngineConfig:
ParserState.TOOL_NAME,
(EventType.TOOL_CALL_START,),
),
(ParserState.CONTENT, "INVOKE_PREFIX"): Transition(
ParserState.TOOL_NAME,
(EventType.TOOL_CALL_START,),
),
(ParserState.TOOL_NAME, "INVOKE_NAME_END"): Transition(
ParserState.TOOL_ARGS,
(),
@@ -84,7 +88,7 @@ def deepseek_v32_config() -> ParserEngineConfig:
(EventType.TOOL_CALL_END,),
),
(ParserState.TOOL_ARGS, "TOOL_END"): Transition(
ParserState.CONTENT,
ParserState.TOOL_BETWEEN,
(EventType.TOOL_CALL_END,),
),
# Parallel tool calls
@@ -92,8 +96,14 @@ def deepseek_v32_config() -> ParserEngineConfig:
ParserState.TOOL_NAME,
(EventType.TOOL_CALL_START,),
),
# A tool call ends the turn: stay in TOOL_BETWEEN so any text
# after the block is dropped.
(ParserState.TOOL_BETWEEN, "TOOL_END"): Transition(
ParserState.CONTENT,
ParserState.TOOL_BETWEEN,
(),
),
(ParserState.TOOL_BETWEEN, "TOOL_START"): Transition(
ParserState.TOOL_PREAMBLE,
(),
),
},
+12 -2
View File
@@ -177,6 +177,10 @@ def deepseek_v4_config(thinking: bool = False) -> ParserEngineConfig:
ParserState.TOOL_NAME,
(EventType.TOOL_CALL_START,),
),
(ParserState.CONTENT, "INVOKE_PREFIX"): Transition(
ParserState.TOOL_NAME,
(EventType.TOOL_CALL_START,),
),
(ParserState.TOOL_NAME, "INVOKE_NAME_END"): Transition(
ParserState.TOOL_ARGS,
(),
@@ -186,7 +190,7 @@ def deepseek_v4_config(thinking: bool = False) -> ParserEngineConfig:
(EventType.TOOL_CALL_END,),
),
(ParserState.TOOL_ARGS, "TOOL_END"): Transition(
ParserState.CONTENT,
ParserState.TOOL_BETWEEN,
(EventType.TOOL_CALL_END,),
),
# Parallel tool calls
@@ -194,8 +198,14 @@ def deepseek_v4_config(thinking: bool = False) -> ParserEngineConfig:
ParserState.TOOL_NAME,
(EventType.TOOL_CALL_START,),
),
# A tool call ends the turn: stay in TOOL_BETWEEN so any text
# after the block is dropped.
(ParserState.TOOL_BETWEEN, "TOOL_END"): Transition(
ParserState.CONTENT,
ParserState.TOOL_BETWEEN,
(),
),
(ParserState.TOOL_BETWEEN, "TOOL_START"): Transition(
ParserState.TOOL_PREAMBLE,
(),
),
},