Repository navigation
Conversation
## summary
- Replace the single-per-project `active` slot with a `Chain` that covers the
running turn together with the messages queued behind it, so the moment
between one turn ending and the next starting stays closed.
- Accept a supplementary message while a turn runs: `POST /assistant/messages`
starts a turn when the project is idle and answers 202 with the queued
message when one is running. The message is stored in the conversation at
once, shows up as `queued`, and starts when the active turn ends.
- Give every event a `seq`, let `GET /turns/{id}/events?after=` resume from a
cursor, and keep one stream across turns: an `end` frame that carries
`nextTurnId` means the next reply continues on the same connection.
- Stopping ends the whole chain and marks messages that never started as
`cancelled`, so a stopped run cannot leave work that begins later by surprise.
## validation
- `python -m pytest tests/test_assistant_queue.py tests/test_assistant_conversations.py -q`
→ 35 passed.
- Full `tests/` run against the same environment: the failures that remain
(missing libx264 / ffmpeg options on this host) are identical with and
without this change.
- `lint-imports` and `python scripts/generate_contracts.py --check` pass.
Refs: ThinkFlowLab#379
A viewer that lost the connection between two turns holds the turn it saw last, which is already finished while its chain keeps writing. Asking for that turn's stream answered 404, so the only way back was a reload. The turn is looked up in the conversation it belongs to and compared with the running chain's conversation, so a stale turn of the same thread finds the stream while a turn from anywhere else is still refused.
|
Pushed one more commit to this branch rather than opening a follow-up PR, because it fixes something this PR itself introduces. What broke. Before chains, one reply meant one stream: a viewer that lost the connection either got the run back or got What changed.
Test. Also: the test fixtures now release their gates on teardown, which took ~10s off the queue suite (a cancelled run was leaving a worker thread waiting). |
Summary
activeslot with aChainthat covers the running turn together with the messages queued behind it, so the moment between one turn ending and the next starting stays closed.POST /assistant/messagesaccepts a message while a turn runs: when the project is idle it starts a turn exactly likePOST /turns, and when a turn is running it answers202with the queued message, stores it in the conversation asqueued, and starts it when the active turn ends. This is the backend half of [feat] assistant: accept a follow-up message while a turn is still running / 运行中插入补充消息 #379.seq,GET /turns/{id}/events?after=resumes from a cursor, and one stream spans turns: anendframe withnextTurnIdmeans the next reply continues on the same connection, so a client can queue without polling.cancelled, so a stopped run cannot leave work that begins later by surprise.POST /turnskeeps its current contract, including reporting a staleconversationIdin the stream rather than as a status code.Linked issue
Refs #379— the issue stays open until the composer and the runtime-native steering land.Refs #379is includedLabels
wtz2333) cannot add labels here — GitHub refusesAddLabelsToLabelablefor this repository. Suggested:type:feat,area:agent,area:harness,needs-design.Test plan
python -m pytest tests/test_assistant_queue.py tests/test_assistant_conversations.py -q→ 35 passed.python -m pytest tests -q --ignore=tests/browser→ the failures that remain are host-environment ones (this machine's ffmpeg lackslibx264and some options); the same set fails identically with the change stashed.lint-imports→ 4 contracts kept.python scripts/generate_contracts.py --check→ verified.Evidence that it works
tests/test_assistant_queue.py(queue while running, chained stream, cursor resume, stop cancels the chain, rejection before queueing, idle start). A screen recording will accompany the composer pull request.Provider verification
AgentRuntimes.streamwith a model double, as the existing assistant tests do.Bilingual UI
409detail andcodefollow the pattern the existing assistant routes already use; the localized composer copy ships with the frontend pull request in both locales.