mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4341] [CLOSED] [Engine] serve: STRATA_ADMIT_SHORT_FIRST orders the single-stream queue too #5016
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#5016
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/4341
Author: @suifei
Created: 10/27/2026
Status: ❌ Closed
Base:
main← Head:feat/single-stream-short-first📝 Commits (1)
d9569fd[Engine] serve: STRATA_ADMIT_SHORT_FIRST orders the single-stream queue too📊 Changes
2 files changed (+109 additions, -15 deletions)
View changed files
📝
serve/server.py(+52 -15)📝
serve/test_queue_keepalive.py(+57 -0)📄 Description
Problem
Without
--batchthe single turn is strictly first come, first served (Service.fifo). A short request - a chatquestion, a health check, a tool's side request - waits behind every agent prompt that arrived before it, including the
decode of a long answer, even though
STRATA_ADMIT_SHORT_FIRSTalready gives it priority in the batched queue. On thisbox a queued request can wait one whole agent turn (~1-2 min), with keep-alives so it does not time out, but it waits.
Result
With the same opt-in setting (
STRATA_ADMIT_SHORT_FIRST; unset or0keeps the old behaviour exactly), the requestswaiting for the single turn are ordered as
StrataEngine._admit_nextorders them:STRATA_ADMIT_SHORT_FIRSTtokens goes before longer ones, arrival order within the short group andwithin the long group;
STRATA_ADMIT_MAX_WAIT_S(default 30 s) counts as short, so a long request is never heldback for good;
QUEUE_BEAT_S, and a client that leaves while queued gives itsplace up.
Validation
Revision
d9569fd(branchfeat/single-stream-short-first). Unit tests use the mock engine on this revision.Passed:
python -m unittest serve.test_queue_keepalive: 6 tests - the 3 existing ones plus 3 new: a late short request takes the turn first over three rounds; the age-out restores arrival order; an ordered waiter still beats and drops out when its client leaves. The 3 new tests fail cleanly onmain(no ordering).fifo.acquireloop as before.Failed, unrelated:
servesuite (1038 tests) has two failures:test_lifeline's watcher, which fails on unmodified code in this container, andtest_responses.NoLeakedSampler, which fails 4 of 6 runs on unmodifiedmainwhen it runs aftertest_queue_keepalive(a leftover sampler thread from the previous test).Not run:
--batchpath, which has its own_admit_nextordering already.Usage
STRATA_ADMIT_SHORT_FIRST=2048(tokens) turns it on. If the long requests are agent turns that take minutes, raiseSTRATA_ADMIT_MAX_WAIT_Stoo (e.g. 300), otherwise a long request that has waited only 30 s is treated as short and theordering does little.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.