Skip to content

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

Merged
chaunceyjiang merged 1 commit into
vllm-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 into
vllm-project:mainfrom
sfeng33:cleanup-tool-p2

Conversation

@sfeng33

@sfeng33 sfeng33 commented Mar 26, 2026

Copy link
Copy Markdown
Collaborator

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread vllm/tool_parsers/abstract_tool_parser.py
@sfeng33 sfeng33 marked this pull request as ready for review March 26, 2026 05:02

@claude claude Bot left a comment

Copy link
Copy Markdown

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

sfeng33 commented Mar 26, 2026

Copy link
Copy Markdown
Collaborator Author

@chaunceyjiang @bbrowning

@bbrowning bbrowning left a comment

Copy link
Copy Markdown
Collaborator

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

sfeng33 commented Mar 26, 2026

Copy link
Copy Markdown
Collaborator Author

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.

Comment thread vllm/tool_parsers/abstract_tool_parser.py
@mergify

mergify Bot commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

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

sfeng33 commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator Author

Resolved conflict

@mergify mergify Bot removed the needs-rebase label Mar 30, 2026
@sfeng33

sfeng33 commented Mar 31, 2026

Copy link
Copy Markdown
Collaborator Author

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

@chaunceyjiang chaunceyjiang left a comment

Copy link
Copy Markdown
Collaborator

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

mergify Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

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

sfeng33 commented Mar 31, 2026

Copy link
Copy Markdown
Collaborator Author

@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>
puririshi98 pushed a commit to puririshi98/vllm that referenced this pull request Apr 7, 2026
…rsers (vllm-project#38189)

Signed-off-by: sfeng33 <4florafeng@gmail.com>
Signed-off-by: Rishi Puri <riship@nvidia.com>
mtparet pushed a commit to blackfuel-ai/vllm that referenced this pull request Apr 9, 2026
mystous pushed a commit to mystous/vllm_hybrid that referenced this pull request May 10, 2026
my-other-github-account pushed a commit to my-other-github-account/vllm that referenced this pull request May 15, 2026
my-other-github-account pushed a commit to my-other-github-account/vllm that referenced this pull request May 15, 2026
jhu960213 pushed a commit to jhu960213/vllm that referenced this pull request May 20, 2026
mvanhorn pushed a commit to mvanhorn/vllm that referenced this pull request Jun 4, 2026
…rsers (vllm-project#38189)

Signed-off-by: sfeng33 <4florafeng@gmail.com>
Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
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