Skip to content

server: reject empty prompts instead of ending the generation thread - #2043

Closed
Tigerly1 wants to merge 1 commit into
ml-explore:mainfrom
Tigerly1:server-reject-empty-prompt
Closed

Tigerly1 wants to merge 1 commit into
ml-explore:mainfrom
Tigerly1:server-reject-empty-prompt

Conversation

@Tigerly1

@Tigerly1 Tigerly1 commented Nov 7, 2026

Copy link
Copy Markdown

An empty tokenized prompt crashes the batched server.

  • Trigger: "prompt": "" with a tokenizer that adds no BOS token.
  • Failure: the request reaches BatchGenerator.insert_segments, which raises ValueError("Sequence ... has an empty prompt.") inside the generation thread.
  • Effect: the thread exits and every later request fails, until the server is restarted.

This PR:

#1513 / #1909 track the general "keep the generation loop alive" problem. This is the narrow fix for one trigger.

Test: test_empty_prompt_is_rejected_and_server_survives. It sends an empty prompt (expects 400), then a normal request (expects 200). It fails on main and passes with this change; all 44 tests in tests/test_server.py pass.

🤖 Generated with Claude Code

An empty tokenized prompt (e.g. "prompt": "" with a tokenizer that adds no
BOS) reached BatchGenerator.insert_segments, which raises ValueError inside the
generation thread. The thread ended, and every later request failed.

Reject the request with 400 before it is inserted; the server keeps serving.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Tigerly1 Tigerly1 closed this Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant