Skip to content

[Rust Frontend] Recover buffered text from incomplete tool calls at EOS - #47289

Merged
BugenZhao merged 2 commits into
vllm-project:mainfrom
reidliu41:fix-gemma4-eos-buffer
Jul 3, 2026
Merged

[Rust Frontend] Recover buffered text from incomplete tool calls at EOS#47289
BugenZhao merged 2 commits into
vllm-project:mainfrom
reidliu41:fix-gemma4-eos-buffer

Conversation

@reidliu41

@reidliu41 reidliu41 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Purpose

When a Gemma4 tool-call stream is truncated before the closing marker, Gemma4UnifiedParser::finish() returns an incomplete-tool-call error while the raw tool-call text remains buffered inside the parser. The unified stream wrapper previously closed parser state without recovering that buffer, so clients could receive only Done and an empty assistant message.

This PR mirrors the existing mid-stream parse-error fallback for end-of-stream finish errors: reset the parser, emit the recovered buffered text as a plain text delta, and close any open tool-call state. It also adds coverage for both the generic finish-error path and a real Gemma4 truncated tool-call stream.

Test Plan

Test Result

cargo test -p vllm-chat unified_stream_finish_error_recovers_buffered_text -- --nocapture
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.17s
     Running unittests src/lib.rs (target/debug/deps/vllm_chat-59266da177b74ae3)

running 1 test
test output::default::unified::tests::unified_stream_finish_error_recovers_buffered_text ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 179 filtered out; finished in 0.00s

     Running tests/chat.rs (target/debug/deps/chat-cd39677c8b0b7af8)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 17 filtered out; finished in 0.00s

     Running tests/roundtrip.rs (target/debug/deps/roundtrip-097e04ca5d9e4d96)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 15 filtered out; finished in 0.00s

cargo test -p vllm-chat unified_stream_recovers_incomplete_gemma4_tool_call_at_eos -- --nocapture
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.10s
     Running unittests src/lib.rs (target/debug/deps/vllm_chat-59266da177b74ae3)

running 1 test
test output::default::unified::tests::unified_stream_recovers_incomplete_gemma4_tool_call_at_eos ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 179 filtered out; finished in 0.00s

     Running tests/chat.rs (target/debug/deps/chat-cd39677c8b0b7af8)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 17 filtered out; finished in 0.00s

     Running tests/roundtrip.rs (target/debug/deps/roundtrip-097e04ca5d9e4d96)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 15 filtered out; finished in 0.00s

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.

Signed-off-by: reidliu41 <reid201711@gmail.com>

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

@mergify mergify Bot added the rust label Jul 1, 2026
@BugenZhao

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: a15883a650

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@BugenZhao BugenZhao 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!

@BugenZhao BugenZhao added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 3, 2026
@BugenZhao
BugenZhao enabled auto-merge (squash) July 3, 2026 03:19
@BugenZhao
BugenZhao merged commit 9b8e765 into vllm-project:main Jul 3, 2026
22 checks passed
jakki-amd pushed a commit to jakki-amd/vllm that referenced this pull request Jul 6, 2026
lkk12014402 pushed a commit to lkk12014402/vllm that referenced this pull request Jul 8, 2026
mayuyuace pushed a commit to mayuyuace/vllm that referenced this pull request Jul 9, 2026
…OS (vllm-project#47289)

Signed-off-by: reidliu41 <reid201711@gmail.com>
Signed-off-by: mayuyuace <qiming1.zhang@intel.com>
NickLucche pushed a commit to NickLucche/vllm that referenced this pull request Jul 15, 2026
philippesic pushed a commit to philippesic/vllm-semantic-cache that referenced this pull request Jul 19, 2026
plasticchris pushed a commit to plasticchris/vllm that referenced this pull request Jul 20, 2026
aditi-amd pushed a commit to aditi-amd/vllm that referenced this pull request Aug 4, 2026
…OS (vllm-project#47289)

Signed-off-by: reidliu41 <reid201711@gmail.com>
Signed-off-by: root <root@smci355-ccs-aus-m02-09.cs-aus.dcgpu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed rust

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants