[OpenAI] Fix tool_choice=required streaming when output has trailing extra data#31610
Merged
chaunceyjiang merged 2 commits intovllm-project:mainfrom Jan 8, 2026
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request addresses an issue in streaming mode with tool_choice="required" where trailing data after a valid JSON tool call would cause a parsing error. The fix correctly uses a partial JSON parser that tolerates extra data. The changes are logical and a regression test is included. I've provided two suggestions to improve the code: one to make the new test case more robust by adding specific assertions, and another to simplify exception handling by combining redundant except blocks.
Signed-off-by: maylikenoother <ogedengbemary19@gmail.com>
7a2b04e to
3d83932
Compare
Contributor
Author
@chaunceyjiang |
yugong333
pushed a commit
to yugong333/vllm
that referenced
this pull request
Jan 9, 2026
…extra data (vllm-project#31610) Signed-off-by: maylikenoother <ogedengbemary19@gmail.com> Co-authored-by: Chauncey <chaunceyjiang@gmail.com>
akh64bit
pushed a commit
to akh64bit/vllm
that referenced
this pull request
Jan 16, 2026
…extra data (vllm-project#31610) Signed-off-by: maylikenoother <ogedengbemary19@gmail.com> Co-authored-by: Chauncey <chaunceyjiang@gmail.com>
dsuhinin
pushed a commit
to dsuhinin/vllm
that referenced
this pull request
Jan 21, 2026
…extra data (vllm-project#31610) Signed-off-by: maylikenoother <ogedengbemary19@gmail.com> Co-authored-by: Chauncey <chaunceyjiang@gmail.com> Signed-off-by: dsuhinin <suhinin.dmitriy@gmail.com>
ItzDEXX
pushed a commit
to ItzDEXX/vllm
that referenced
this pull request
Feb 19, 2026
…extra data (vllm-project#31610) Signed-off-by: maylikenoother <ogedengbemary19@gmail.com> Co-authored-by: Chauncey <chaunceyjiang@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
When using tool_choice="required", OpenAIServingChat.extract_tool_call_required_streaming parses the partial stream as JSON. If the model emits a valid JSON tool-call array and then continues with trailing tokens (e.g. "\nDONE"), parsing can hit a JSON "Extra data" case and stop/behave incorrectly.
Fix:
Tests: