mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4758] [Engine] send the stream role with the first response data #5166
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5166
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4758
Author: @Tsury
Created: 10/30/2026
Status: 🔄 Open
Base:
main← Head:fix-first-chunk📝 Commits (1)
ce82e6f[Engine] send the stream role with the first response data📊 Changes
2 files changed (+169 additions, -1 deletions)
View changed files
📝
serve/server.py(+21 -1)➕
serve/test_first_chunk.py(+148 -0)📄 Description
Problem and result
openai_chunkssends the role-only chunk before the prompt is read. A client that times the first data chunk then measures about 0 ms of prefill (#2391, llama-benchy's TTFR andest_ppt). vLLM and llama.cpp send it with the engine's first output.After this change, the role goes out once, right before the first data chunk. Keep-alive comments are not data and may go first. A progress chunk counts as data.
Related discussion
#2391. Based on #2480 by @KeyanHu-git, which its author closed as a draft on Oct 22 with no review. The test file comes from that PR. If they would rather carry it on, I will close this one.
Approach
A small
first()generator yields the role chunk once, and every path that emits data calls it first.Validation
Passed:
main(870aedd9): 10 failures. With the change: all pass.python -m unittest serve.test_first_chunk serve.test_server serve.test_structured: 372 tests pass (Linux, Python 3.14).Not run:
python -m unittest discover -s serveand any GPU or model run. This change was split from a maintained v0.2.8 build that runs on an RTX 5090 Laptop; the unit tests above are the evidence for this branch.Limits
A client that reads the role chunk as a sign of life gets it later. Keep-alive comments still arrive during a long prompt read.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.