Repository navigation
Conversation
Backport the streaming stop guard proposed by Ting Sun in vllm-project#46303 (af50313). The equivalent streaming change is also proposed in upstream vllm-project#47963. Preserve length in the non-streaming automatic-tool path as well, and retain existing missing-reason fallbacks. Add real-parser regressions for partial and complete calls, normal stops, named tools and text. Co-authored-by: Ting Sun <suntcrick@gmail.com> Assisted-by: Codex Signed-off-by: logprobz <321553542+logprobz@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughStreaming and non-streaming chat completion paths now preserve truncation and other engine finish reasons instead of reporting ChangesTool-call finish reason handling
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The finish-reason handling change is ready to merge with no concrete current-head risks identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Purpose
Backport the streaming tool-truncation finish-reason correction to
dev/jovian-judgementand fix the additional non-streaming automatic-tool case.When generated tool output reaches its token limit, the response retains
finish_reason="length"instead of reporting a completedtool_callsresponse.This also applies when a complete call was emitted before the engine hit its
limit. Successful automatic/required calls, named calls, ordinary text and the
existing non-streaming missing-reason fallbacks keep their current behavior.
Provenance and duplicate check
vllm-project/vllm#46303,
also present in #47963.
Both remain open against upstream
main; this is an attributed Jovianbackport, not another competing upstream submission.
auto_tools_calledbranch, which alsooverwrites
lengthwhen the parser returns a call. The regression uses theactual DeepSeek V4.1 parser to reproduce it.
different case: required-tool responses with no parsed call. Its behavior
is outside this patch. Jovian Fix Codex tool-call poisoning and fatal KV completion races #701 repairs argument finalization and replay,
not the finish-reason override.
immediately before publication. No equivalent Jovian PR was found.
Test Plan
CPU tests use the complete target Python source at
200b6e23590dfe9bab7adf740cdd9facb979a4ed, with this two-file change. The testcontainer supplies pinned native dependencies without GPU devices. Python 3.12,
Torch 2.13.0, Transformers 5.15.0, tokenizers 0.22.2 and pytest 8.4.1 were used.
The test reuses the suite GPT-2 tokenizer, preserves UTF-8 chunk boundaries,
and executes both response generators with the actual parser.
python -m pytest --confcutdir=tests \ tests/entrypoints/openai/chat_completion/test_serving_chat.py \ -k 'tool_call_preserves_engine_finish_reason or streaming_n_gt1_independent_tool_parsers or tool_choice_validation_without_parser or metrics or prompt_tokens_details or streaming_reasoning_usage' -q pre-commit run --files \ vllm/entrypoints/openai/chat_completion/serving.py \ tests/entrypoints/openai/chat_completion/test_serving_chat.py pre-commit run mypy-3.12 --hook-stage manual --files \ vllm/entrypoints/openai/chat_completion/serving.py \ tests/entrypoints/openai/chat_completion/test_serving_chat.pyTest Result
regression matrix. Four failures were streaming automatic/required calls;
two were non-streaming automatic calls. All six asserted the wrong terminal
finish reason, not setup or parser errors.
and eight existing serving controls.
Python 3.10 typing and source checks. The Python 3.12 typing hook and Python
compilation passed separately.
This is a response-reporting correction. Model generation, sampling and
argument-repair logic are unchanged. No model inference evaluation was run for
this PR, and production GLM was not restarted or modified.
AI assistance: Codex helped prepare, review and test this change.
Summary by CodeRabbit
lengthfinish reason instead of being reported astool_calls.tool_callswhen appropriate.stop.