Skip to content

[Security] Roll back request registration if engine add fails - #56212

Open
jperezdealgaba wants to merge 1 commit into
vllm-project:mainfrom
jperezdealgaba:fix/rollback-failed-engine-add-request
Open

jperezdealgaba wants to merge 1 commit into
vllm-project:mainfrom
jperezdealgaba:fix/rollback-failed-engine-add-request

Conversation

@jperezdealgaba

Copy link
Copy Markdown
Collaborator

Summary

AsyncLLM and LLMEngine register a request in the output processor before sending it to EngineCore. If that send fails (for example MessagePack cannot encode an oversized integer), the local RequestState was left behind with no abort path. This change rolls back registration when engine add fails, and rejects oversized stream_interval / top_k values at the API and SamplingParams layers.

Changes

  • vllm/v1/engine/async_llm.py: abort the registered request if add_request_async fails; abort already-sent siblings when n>1 fan-out fails.
  • vllm/v1/engine/llm_engine.py: same rollback for the sync add path.
  • vllm/sampling_params.py: reject top_k and stream_interval above the MessagePack integer range.
  • OpenAI / Anthropic / speech-to-text protocols: bound top_k and stream_interval like neighboring int64 fields.

Codepath coverage

  • HTTP generate (/v1/chat/completions, /v1/completions, /v1/messages, /v1/responses, /invocations) via AsyncLLM._add_request.
  • Streaming-input chunks that call _add_request.
  • Parallel sampling (n>1) sibling rollback on AsyncLLM.add_request and LLMEngine.add_request.
  • Offline LLMEngine.add_request.
  • Protocol and SamplingParams validation for the reported oversized integer triggers.

Duplicate-work check

Searched open and merged PRs for async_llm _add_request, stream_interval, RequestState leak, top_k int64, and rollback/abort of failed engine add. Related but incomplete: #51629 (ParentRequest leftover on n>1 abort; does not wrap register-then-send), #50101 / #55226 (stream_interval semantics, not bounds or leak), #49754 (exposed per-request stream_interval). No open or merged PR closes this register-then-send window.

Tests

  • test_async_add_request_rolls_back_on_encode_overflow / test_sync_add_request_rolls_back_on_engine_send_failure: real MessagePack overflow after register leaves no RequestState.
  • test_async_parallel_add_rolls_back_siblings_on_later_send_failure / sync counterpart: later child send failure aborts already-sent siblings.
  • test_async_add_request_keeps_state_when_engine_accepts: happy path still registers.
  • Protocol tests reject oversized stream_interval / top_k; SamplingParams rejects values above the MessagePack range.

Commands: .venv/bin/python -m pytest tests/v1/engine/test_add_request_rollback.py tests/entrypoints/unit_tests/test_sampling_int_bounds.py tests/test_sampling_params.py -v (38 passed). pre-commit run --files on the changed files (passed).

AI assistance

This PR was developed with AI assistance.

Made with Cursor

Co-authored-by: Cursor Agent
Signed-off-by: Juan Pérez de Algaba <jperezde@redhat.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 commented Sep 18, 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, @jperezdealgaba.

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 Sep 18, 2026
justtestingthingsx pushed a commit to meandmyboiclaude/vllm that referenced this pull request Sep 19, 2026
…esolution

Both PRs' cleanly-applied hunks wrapped add_request's body in a new try:,
whose insertion point sat OUTSIDE the conflict region. Resolving the
conflict to our side then re-emitted our (upstream a715606) version
below it, so the function carried both copies and the try: had no except
-- a SyntaxError, in a file the commit-time py_compile gate never opened,
because an unmerged path is not listed by git diff --cached --diff-filter=ACM.

Upstream a715606 already provides the restructure both PRs wanted, so
the duplicate block is dropped and our version stands.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant