-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Fix regex patterns in DeepSeekV31ToolParser to use non-greedy matching #23618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Change greedy .* to non-greedy .*? in tool call regex patterns to prevent over-matching when parsing function names and arguments in tool calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request aims to fix issues with greedy regex patterns in the DeepSeekV31ToolParser by making them non-greedy. The changes to tool_call_regex are correct and comprehensive. However, the change to stream_tool_call_portion_regex is incomplete. While the function_name is now non-greedy, the function_arguments group remains greedy (.*), which can cause it to match beyond the intended arguments, including the <|tool call end|> token. I've provided a critical review comment with a suggested fix to make the argument parsing robust and prevent incorrect tool call extraction during streaming.
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run You ask your reviewers to trigger select CI tests on top of Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add If you have any questions, please reach out to us on Slack at https://slack.vllm.ai. 🚀 |
|
#23454 |
Looks good, thanks for your contribution. |
|
@aarnphm |
Fix regex patterns in DeepSeekV31ToolParser to use non-greedy matching
Purpose
Fix tool call parsing issues in DeepSeek V3.1 model by changing greedy regex patterns (.) to non-greedy patterns (.?) in the tool parser. This prevents over-matching when parsing function names and
arguments in tool calls, which could lead to incorrect extraction of tool call information from model outputs.
The issue occurs when the model output contains multiple tool separators or special tokens, causing the greedy patterns to match beyond the intended boundaries.
Test Plan
Test the regex pattern changes with various tool call scenarios: