mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4340] [CLOSED] [Engine] serve: keep a long prompt read alive for clients that count events #5015
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#5015
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/4340
Author: @suifei
Created: 10/27/2026
Status: ❌ Closed
Base:
main← Head:fix/read-heartbeat📝 Commits (2)
e450b05[Engine] serve: keep a long prompt read alive for clients that count events66e0edftest(serve): the read beat on the chat and anthropic streams, not just the structured one📊 Changes
3 files changed (+100 additions, -2 deletions)
View changed files
📝
serve/server.py(+36 -2)📝
serve/test_queue_keepalive.py(+37 -0)📝
serve/test_structured.py(+27 -0)📄 Description
Problem
While a long prompt is read, the streams sent only SSE comments (
: keep-alive). A client whose idle timer counts theevents it parses never sees those, so a long read looks like a dead connection. Measured on a 45K-token read: 434
comments and 7 data events, the largest gap between data events 34.0 s - the whole read; a 190K-233K prompt is 100-120 s
of the same. One client's 300 s stream-idle timeout took a request down mid-read, and its retry read the prompt again.
What changes (streams only; single stream included)
/v1/chat/completions: an empty delta everyPREFILL_BEAT_S(5 s) while the prompt is read. Every OpenAI clientignores an empty delta; the response content and the final chunk are unchanged.
response_format: an empty delta is passed through untouched (_empty_delta) instead of being held inthe validation buffer, so the beat reaches the client during the read instead of with the answer. The buffered,
validated answer still goes out exactly as before.
/v1/messages: Anthropic's ownevent: pingeveryPREFILL_BEAT_S, and the plain comment between two beats.openai_chunksis kept.Cost: one small chunk every 5 s while a prompt is read.
Validation
Revision
66e0edf(branchfix/read-heartbeat). Tests and measurements run on this revision.Passed:
python -m unittest serve.test_structured: 11 tests, 2 skipped (includes the newtest_a_read_beat_reaches_the_client_before_the_answer, which checks the beat is out before the next chunk is generated).python -m unittest serve.test_queue_keepalive: 3 tests (the comment between beats is what it checks)./v1/messageson the same read: 5 pings + 18 data events; the structured read: 5 empty deltas spread over the read.Failed:
Not run:
servesuite in CI. On the batching branch it ran 1045 tests with one failure in the process-lifeline watcher, which fails on an unmodified checkout of this branch too (environment: this container).Note
This is independent of the batch/step work: a single-stream deployment hits the same timeout. The batching branch
(
feat/dsv41-batch-m1) carries the same change as part of PR #4199; this branch is that change alone.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.