Skip to content

[Tool Parser][2/3] Use self.tools instead of request.tools in tool parsers#38189

Merged
chaunceyjiang merged 1 commit intovllm-project:mainfrom
sfeng33:cleanup-tool-p2
Mar 31, 2026
Merged

[Tool Parser][2/3] Use self.tools instead of request.tools in tool parsers#38189
chaunceyjiang merged 1 commit intovllm-project:mainfrom
sfeng33:cleanup-tool-p2

Conversation

@sfeng33
Copy link
Copy Markdown
Contributor

@sfeng33 sfeng33 commented Mar 26, 2026

Purpose

  • Migrate tool parsers to read tools from self.tools (set at construction) instead of request.tools at call time. This is part 2 of the tool parser cleanup series following [Tool Parser][1/3] Pass tools to ToolParser constructor #38029.
  • Update the base ToolParser.__init__ to filter and store only ChatCompletionToolsParam | FunctionTool instances
  • Update tests to pass tools at parser construction rather than only via request

Test Plan

pytest tests/tool_parsers

@mergify mergify bot added deepseek Related to DeepSeek models qwen Related to Qwen models tool-calling labels Mar 26, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 refactors the tool parsing logic by centralizing the tools definition within the AbstractToolParser instance, making it accessible via self.tools instead of passing it as an argument to individual methods. This change simplifies method signatures and streamlines tool management across various tool parsers and their tests. A potential issue was identified in vllm/tool_parsers/abstract_tool_parser.py where the __init__ method's filtering logic for tools might incorrectly exclude valid FunctionTool definitions if they are provided as plain dictionaries, due to the behavior of isinstance with TypedDict.

@sfeng33 sfeng33 marked this pull request as ready for review March 26, 2026 05:02
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@sfeng33
Copy link
Copy Markdown
Contributor Author

sfeng33 commented Mar 26, 2026

@chaunceyjiang @bbrowning

Copy link
Copy Markdown
Contributor

@bbrowning bbrowning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks straightforward and a reasonable follow-up to the 1st PR in this series. One note is the _WrappedParser in vllm/parser/abstract_parser.py doesn't pass in tools at all here. I think that's ok for now based on where that gets used in the Responses API path, but we may want to confirm whether that needs some changes as we get to step 3.

@sfeng33
Copy link
Copy Markdown
Contributor Author

sfeng33 commented Mar 26, 2026

This looks straightforward and a reasonable follow-up to the 1st PR in this series. One note is the _WrappedParser in vllm/parser/abstract_parser.py doesn't pass in tools at all here. I think that's ok for now based on where that gets used in the Responses API path, but we may want to confirm whether that needs some changes as we get to step 3.

Thanks Ben, this is great reminder to update the unified parser. On a side note - step 3 is blocked util deprecation period is reached.

@mergify
Copy link
Copy Markdown

mergify bot commented Mar 30, 2026

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @sfeng33.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@sfeng33
Copy link
Copy Markdown
Contributor Author

sfeng33 commented Mar 30, 2026

Resolved conflict

@mergify mergify bot removed the needs-rebase label Mar 30, 2026
@sfeng33
Copy link
Copy Markdown
Contributor Author

sfeng33 commented Mar 31, 2026

@chaunceyjiang would you have any additional comments or feedback on this PR? Thanks!

Copy link
Copy Markdown
Collaborator

@chaunceyjiang chaunceyjiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks~

@chaunceyjiang chaunceyjiang added the ready ONLY add when PR is ready to merge/full CI is needed label Mar 31, 2026
@mergify
Copy link
Copy Markdown

mergify bot commented Mar 31, 2026

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @sfeng33.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Mar 31, 2026
@chaunceyjiang
Copy link
Copy Markdown
Collaborator

Please rebase the PR

Signed-off-by: sfeng33 <4florafeng@gmail.com>
@sfeng33
Copy link
Copy Markdown
Contributor Author

sfeng33 commented Mar 31, 2026

@chaunceyjiang all tests have passed.

@chaunceyjiang chaunceyjiang merged commit d53cb9c into vllm-project:main Mar 31, 2026
47 checks passed
@sfeng33 sfeng33 deleted the cleanup-tool-p2 branch March 31, 2026 06:04
neweyes pushed a commit to neweyes/vllm that referenced this pull request Mar 31, 2026
…rsers (vllm-project#38189)

Signed-off-by: sfeng33 <4florafeng@gmail.com>
Signed-off-by: neweyes <328719365@qq.com>
bbrowning added a commit to bbrowning/vllm that referenced this pull request Mar 31, 2026
…llm-project#38189)

After the refactor in vllm-project#38189 to use self.tools instead of request.tools,
anyOf regression tests need to provide tools at parser construction time
so the schema is available for type resolution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Signed-off-by: Ben Browning <bbrownin@redhat.com>
EricccYang pushed a commit to EricccYang/vllm that referenced this pull request Apr 1, 2026
…rsers (vllm-project#38189)

Signed-off-by: sfeng33 <4florafeng@gmail.com>
Signed-off-by: EricccYang <yangyang4991@gmail.com>
bhargav-patel-29 pushed a commit to Bharatgen-Tech/vllm that referenced this pull request Apr 1, 2026
…rsers (vllm-project#38189)

Signed-off-by: sfeng33 <4florafeng@gmail.com>
Signed-off-by: bhargav-patel-29 <bhargav.patel@tihiitb.org>
yzong-rh pushed a commit to yzong-rh/vllm that referenced this pull request Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepseek Related to DeepSeek models qwen Related to Qwen models ready ONLY add when PR is ready to merge/full CI is needed tool-calling

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants