Skip to content

[Bugfix] Fix unstreamed tool call args dropped in Responses API streaming - #44348

Merged
sfeng33 merged 2 commits into
vllm-project:mainfrom
sfeng33:response-flush
Jun 3, 2026
Merged

sfeng33 merged 2 commits into
vllm-project:mainfrom
sfeng33:response-flush

Conversation

@sfeng33

@sfeng33 sfeng33 commented Jun 2, 2026

Copy link
Copy Markdown
Member

Purpose

When tool parsers stream arguments incrementally, they may buffer chunks that haven't been sent to the client yet. On the final streaming delta, parse_delta(finished=True) calls _append_unstreamed_tool_args(), which computes the diff between the fully-parsed arguments and what was actually streamed, and appends the remainder. Without this flush, the client receives truncated or empty tool call arguments.

The chat completions path already passes finished correctly. This PR extends the same fix to the Responses API path.

Test Plan

Verify the final streamed event contains complete tool call arguments (e.g. {"location": "San Francisco"}) rather than truncated.

vllm serve Qwen/Qwen3-0.6B --enable-auto-tool-choice --tool-call-parser hermes

- Send a streaming Responses API request with a tool/function definition that produces multi-token arguments:
curl -X POST http://localhost:8000/v1/responses \
  -H "Content-Type: application/json" \
  -d '{
    "model": "Qwen/Qwen3-0.6B",
    "stream": true,
    "input": "What is the weather in San Francisco?",
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get the current weather for a location",
        "parameters": {
          "type": "object",
          "properties": {
            "location": {"type": "string"}
          },
          "required": ["location"]
        }
      }
    }]

Signed-off-by: sfeng33 <4florafeng@gmail.com>
@sfeng33
sfeng33 marked this pull request as ready for review June 2, 2026 18:46

@yzong-rh yzong-rh 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.

LGTM thx~

@bbrowning bbrowning 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.

Looks good to me. At first I was slightly concerned about the signature change for how the finished parameter is defined in the abstract parser. But, then I realized we only added that very recently so the odds of this breaking any 3rd party code in the wild is extremely low.

@mergify mergify Bot added frontend bug Something isn't working labels Jun 2, 2026
@sfeng33 sfeng33 added the ready ONLY add when PR is ready to merge/full CI is needed label Jun 3, 2026
@sfeng33
sfeng33 enabled auto-merge (squash) June 3, 2026 04:08
@sfeng33
sfeng33 merged commit 209709a into vllm-project:main Jun 3, 2026
53 checks passed
@sfeng33
sfeng33 deleted the response-flush branch June 3, 2026 14:42
nkzhenhua pushed a commit to nkzhenhua/vllm that referenced this pull request Jun 24, 2026
philippesic pushed a commit to philippesic/vllm-semantic-cache that referenced this pull request Jul 19, 2026
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 ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants