Skip to content

[Bug]: finish_reason="tool_calls" is returned with an empty tool_calls array when tool_choice="re... - #53258

Closed
SayHelloToWorld wants to merge 1 commit into
vllm-project:mainfrom
SayHelloToWorld:fix/issue-53255
Closed

SayHelloToWorld wants to merge 1 commit into
vllm-project:mainfrom
SayHelloToWorld:fix/issue-53255

Conversation

@SayHelloToWorld

Copy link
Copy Markdown
Contributor

Fixes #53255

AI-assisted, auto-generated by the vLLM issue bot (Copilot Agent).
No existing open PR addresses this issue (checked before opening).

Summary

  • Root cause: non-streaming path set finish_reason="tool_calls" when tool_choice=="required" without verifying any tool_calls existed.
  • Fix: require non-empty tool_calls before mapping stop->"tool_calls".
  • Tests: added a minimal non-streaming unit test asserting finish_reason=="stop" when tool_choice="required" produces no calls.
    What changed
  • vllm/entrypoints/openai/chat_completion/serving.py
    • Guarded the non-streaming finish_reason decision with and bool(tool_calls).
  • tests/entrypoints/openai/chat_completion/test_chat_error.py
    • Added test_required_tool_choice_no_calls_non_stream_finish_reason asserting the response finish_reason is "stop".
      Commit & push
  • Created branch fix/issue-53255 and committed the change with Co-authored-by trailer.
  • Attempted to push to origin but push failed due to lack of GitHub credentials:
    fatal: could not read Username for 'https://github.com': terminal prompts disabled
    Next steps for a human maintainer
  1. Review the two-file diff (sm...

…oduced\n

Auto-fix: require non-empty tool_calls for required tool_choice to set tool_calls finish_reason

Fixes vllm-project#53255

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mergify mergify Bot added frontend bug Something isn't working labels Aug 21, 2026
@longluubao

Copy link
Copy Markdown
Contributor

Heads-up for reviewers: this overlaps #53256, which fixes the same issue and was opened ~15 minutes before this one (#53256 at 11:52:55Z, this at 12:07:37Z). The bot's note that "no existing open PR addresses this issue" was not accurate at the time it was written.

The code change is the same idea in both. #53256 additionally carries the end-to-end measurement behind the report — unpatched vs patched on the same host and image, with the tool parser off and on — showing finish_reason going from "tool_calls" to "stop" when no call is produced, and staying "tool_calls" when one is.

I'm the author of both #53255 and #53256, so I have no objection to whichever one a maintainer prefers to take; flagging it only so the same change doesn't get reviewed twice.

@SayHelloToWorld

Copy link
Copy Markdown
Contributor Author

@longluubao Ok, I will close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: finish_reason="tool_calls" is returned with an empty tool_calls array when tool_choice="required" produces no call

2 participants