Skip to content

[Bugfix] Fixed when return_token_ids=False, the first event still contains prompt_token_ids. - #27561

Merged
DarkLight1337 merged 2 commits into
vllm-project:mainfrom
chaunceyjiang:return_token_ids
Oct 27, 2025
Merged

[Bugfix] Fixed when return_token_ids=False, the first event still contains prompt_token_ids.#27561
DarkLight1337 merged 2 commits into
vllm-project:mainfrom
chaunceyjiang:return_token_ids

Conversation

@chaunceyjiang

@chaunceyjiang chaunceyjiang commented Oct 27, 2025

Copy link
Copy Markdown
Collaborator

Purpose

Follow up #22587

FIX #27336

return_token_ids: bool | None = Field(
default=None,
description=(
"If specified, the result will include token IDs alongside the "
"generated text. In streaming mode, prompt_token_ids is included "
"only in the first chunk, and token_ids contains the delta tokens "
"for each chunk. This is useful for debugging or when you "
"need to map generated text back to input tokens."
),
)

Test Plan

echo
curl http://localhost:8000/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
    "prompt": "Once upon a time, there was a brave knight named",
    "stream": true,
    "temperature": 0.7
}'

main:

data: {"id":"cmpl-bb3c414e6a24489c8a25bd07b6c86394","object":"text_completion","created":1761553425,"model":"/home/jovyan/qwen3-8b","choices":[{"index":0,"text":" Sir","logprobs":null,"finish_reason":null,"stop_reason":null,"prompt_token_ids":[12522,5193,264,882,11,1052,572,264,33200,46609,6941],"token_ids":null}],"usage":null}

this pr:

data: {"id":"cmpl-d1eb817714c94cb2b5fb559b5d2fd7fa","object":"text_completion","created":1761553358,"model":"/home/jovyan/qwen3-8b","choices":[{"index":0,"text":" Sir","logprobs":null,"finish_reason":null,"stop_reason":null,"prompt_token_ids":null,"token_ids":null}],"usage":null}

Test Result


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

…ains prompt_token_ids.

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
@chaunceyjiang

Copy link
Copy Markdown
Collaborator Author

/cc @ultmaster PTAL.

@mergify mergify Bot added the frontend label Oct 27, 2025
…ains prompt_token_ids.

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
@chaunceyjiang

Copy link
Copy Markdown
Collaborator Author

Follow up #22587

/cc @njhill @youkaichao @DarkLight1337 PTAL.

@DarkLight1337

DarkLight1337 commented Oct 27, 2025

Copy link
Copy Markdown
Member

Fixed when return_token_ids=True

You mean when return_token_ids=False?

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread tests/entrypoints/openai/test_return_token_ids.py
@chaunceyjiang chaunceyjiang changed the title [Bugfix] Fixed when return_token_ids=True, the first event still contains prompt_token_ids. [Bugfix] Fixed when return_token_ids=False, the first event still contains prompt_token_ids. Oct 27, 2025
@chaunceyjiang

Copy link
Copy Markdown
Collaborator Author

You mean when return_token_ids=False?

ohh, yes. thanks~

@DarkLight1337 DarkLight1337 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for fixing!

@DarkLight1337
DarkLight1337 enabled auto-merge (squash) October 27, 2025 08:48
@github-actions github-actions Bot added the ready ONLY add when PR is ready to merge/full CI is needed label Oct 27, 2025
@ultmaster

Copy link
Copy Markdown
Contributor

I've looked at the PR and it seems to be a bug introduced by me. Sorry. The PR looks good.

@DarkLight1337
DarkLight1337 merged commit a4fc218 into vllm-project:main Oct 27, 2025
50 checks passed
@chaunceyjiang
chaunceyjiang deleted the return_token_ids branch October 27, 2025 12:13
ilmarkov pushed a commit to neuralmagic/vllm that referenced this pull request Nov 7, 2025
…tains prompt_token_ids. (vllm-project#27561)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
ZhengHongming888 pushed a commit to ZhengHongming888/vllm that referenced this pull request Nov 8, 2025
…tains prompt_token_ids. (vllm-project#27561)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
rtourgeman pushed a commit to rtourgeman/vllm that referenced this pull request Nov 10, 2025
…tains prompt_token_ids. (vllm-project#27561)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
devpatelio pushed a commit to SumanthRH/vllm that referenced this pull request Nov 29, 2025
…tains prompt_token_ids. (vllm-project#27561)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
mystous pushed a commit to mystous/vllm_hybrid that referenced this pull request May 10, 2026
…tains prompt_token_ids. (vllm-project#27561)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
my-other-github-account pushed a commit to my-other-github-account/vllm that referenced this pull request May 15, 2026
…tains prompt_token_ids. (vllm-project#27561)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
my-other-github-account pushed a commit to my-other-github-account/vllm that referenced this pull request May 15, 2026
…tains prompt_token_ids. (vllm-project#27561)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
0826joyce pushed a commit to 0826joyce/vllm-serving-optimization that referenced this pull request May 19, 2026
…tains prompt_token_ids. (vllm-project#27561)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
plasticchris pushed a commit to plasticchris/vllm that referenced this pull request Jul 20, 2026
…tains prompt_token_ids. (vllm-project#27561)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

[Feature]: Make promt_token_ids optional in streaming response (disable by default)

3 participants