Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions tests/tool_parsers/test_deepseekv31_tool_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,19 @@ def test_extract_tool_calls_with_multiple_tools(parser):
assert result.tool_calls[1].function.name == "bar"
assert result.tool_calls[1].function.arguments == '{"y":2}'

# prefix is content
assert result.content == "some prefix text"
# Text before the block and text after it are both content.
assert result.content == "some prefix text some suffix text"


def test_extract_tool_calls_keeps_text_after_tool_calls(parser):
model_output = (
"<|tool▁calls▁begin|>"
'<|tool▁call▁begin|>foo<|tool▁sep|>{"x":1}<|tool▁call▁end|>'
"<|tool▁calls▁end|>"
"It is 30 degrees."
)
result = parser.extract_tool_calls(model_output, None)
assert result.tools_called
assert result.tool_calls[0].function.name == "foo"
assert result.tool_calls[0].function.arguments == '{"x":1}'
assert result.content == "It is 30 degrees."
14 changes: 13 additions & 1 deletion vllm/tool_parsers/deepseekv31_tool_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,19 @@ def extract_tool_calls(
)
)

content = model_output[: model_output.find(self.tool_calls_start_token)]
# Content spans text before the tool-calls block and text
# after it, matching what the streaming mode emits as
# content deltas (issue #56263).
content_start = model_output[
: model_output.find(self.tool_calls_start_token)
]
calls_end = model_output.find(self.tool_calls_end_token)
content_tail = (
model_output[calls_end + len(self.tool_calls_end_token) :]
if calls_end != -1
else ""
)
content = content_start + content_tail
return ExtractedToolCallInformation(
tools_called=True,
tool_calls=tool_calls,
Expand Down
Loading