Skip to content

[Bugfix] Keep text after DeepSeek V3.1 tool calls - #59589

Open
pOpO1-9 wants to merge 5 commits into
vllm-project:mainfrom
pOpO1-9:fix/deepseek-v31-post-tool-text
Open

pOpO1-9 wants to merge 5 commits into
vllm-project:mainfrom
pOpO1-9:fix/deepseek-v31-post-tool-text

Conversation

@pOpO1-9

@pOpO1-9 pOpO1-9 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Overview

The DeepSeek V3.1 tool parser dropped any text that came after a tool-calls block on the non-streaming path. Streaming already returned that text. This is the same gap as #56263. #56265 covers the V3 parser only. This change is the V3.1 parser, which is a separate file and still registered as deepseek_v31.

Claims

  • extract_tool_calls returns the text before the tool-calls block plus the text after tool_calls_end.
  • A missing end marker keeps the old behavior: prefix only.
  • Tool names and arguments are unchanged.
  • Streaming is not modified.

Validation

The non-streaming cases were run here with a tiny in-memory tokenizer: prefix only, prefix plus suffix, and suffix only. All three returned the expected content and tool names. ruff check and ruff format --check passed on the two files.

The existing unit tests download deepseek-ai/DeepSeek-V3.1 and were not run on this machine. Importing vLLM here fails before the tokenizer step.

pytest tests/tool_parsers/test_deepseekv31_tool_parser.py

Details

extract_tool_calls used to slice at the start marker and ignore the rest. Streaming emits a content delta once the tool-call start and end counts match again, so the text after the block reaches the client only on the streaming path.


Pull Request Checklist
  • I used vLLM's /pr-checklist skill. (Mandatory for agents, optional for humans).

  • AI assistance was used during the creation of this PR.

  • Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.

  • Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.

  • Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.

  • Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.

Non-streaming parse dropped everything after the tool-calls block.
Streaming already returned that text.

Signed-off-by: Paul El Khoury <82139421+pOpO1-9@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.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.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

PRs do not trigger a full CI run by default. Reviewers with write access and configured trusted contributors can comment /ci run for upstream CI or /amd-ci run for AMD CI only whenever CI signals are needed.

Once the PR is approved or has the ready label, the PR author can also use the corresponding /ci run, /ci retry, and /ci cancel commands, or their /amd-ci variants. New commits do not start upstream CI automatically.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

Agent Guidelines

IMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban.

🚀

Signed-off-by: Artem Perevedentsev <aperevedents@nvidia.com>
@arpera arpera added the ready ONLY add when PR is ready to merge/full CI is needed label Oct 19, 2026
@github-project-automation github-project-automation Bot moved this to Unsorted queue in Tool Calling (arpera) Oct 19, 2026
@arpera

arpera commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

/ci run

@github-actions

Copy link
Copy Markdown

✅ @pOpO1-9, CI is now available for this PR.

  • /ci run starts upstream CI; /amd-ci run starts AMD CI only.
  • Run commands test your branch with every commit currently on its upstream target branch. If it is behind, the bot merges the target branch into it first (pull before pushing again). Append --allow-stale to a run command to test an outdated branch as is, at your own risk.
  • /ci retry retries failed jobs in the CI build for the current PR head. If the current head has no CI build, it starts a new CI build for the current head containing only jobs that failed in the latest earlier CI build for this PR.
  • /amd-ci retry retries failed jobs in AMD CI for the current PR head. Use /amd-ci run when the current head has no AMD CI build.
  • /ci cancel cancels scheduled or running CI builds for this PR branch; /amd-ci cancel does the same for AMD CI only.

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #95889 for commit 48a80553fc3b.

@mergify

mergify Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Hi @pOpO1-9, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Signed-off-by: Artem Perevedentsev <aperevedents@nvidia.com>
@arpera

arpera commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

/ci run

@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #95893 for commit d995db49cad7.

@mergify

mergify Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @pOpO1-9.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Oct 19, 2026
@arpera arpera removed this from Tool Calling Oct 21, 2026

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

LGTM. Tested at d995db4.
I confirmed locally that streaming and non-streaming now agree on text before and after the block.
nit: With text between two tool-call blocks, non-streaming still drops that text, and without an end marker, streaming still returns the text after the last call. V3 does the same on main, so I think this PR is fine as is.

This branch has not been deployed

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

Labels

bug Something isn't working deepseek Related to DeepSeek models needs-rebase ready ONLY add when PR is ready to merge/full CI is needed tool-calling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants