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.
wtz2333
marked this pull request as draft
November 19, 2026 02:22
wtz2333
force-pushed
the
feat/midturn-steer
branch
from
November 19, 2026 03:48
3716172 to
987529d
Compare
Codex now runs as an app-server session instead of a one-shot exec, so a turn has a channel for extra text while it works: POST /assistant/messages with delivery "insert" hands the words to turn/steer and the answer keeps the work it has already done. Runtimes without a native channel refuse the insert and say so, leaving the queued delivery as the fallback.
wtz2333
force-pushed
the
feat/midturn-steer
branch
from
November 19, 2026 04:36
987529d to
0cfba12
Compare
This was referenced Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A reply that is already running can now take one more line of text:
POST /assistant/messageswithdelivery: "insert"hands the text to the running turn instead of waiting for it to end.codex app-server(JSON-RPC over stdio) instead ofcodex exec.execreads one prompt and exits, so nothing could reach the model once a turn started; the app server keeps the turn open and exposesturn/steerandturn/interrupt.appserver.pydrives one turn:initialize→thread/resumeorthread/start→turn/start→turn/steerwhile it runs. A saved thread that cannot be opened falls back to a fresh thread with the whole authoritative history, so a lost rollout never quietly drops the conversation.RuntimeSpec.supportsSteeringstates who can do this; only Codex is true today.POST /messagesrefusesinserton a runtime that cannot steer (409, naming the runtime), when nothing is running (409), when the turn just ended (409), and when the message carries assets, skills or rich content — inserted text is text only.status: "inserted"in the place they arrived (before the streaming reply), and the stream reports{"type": "steered", "message": ...}.Depends on #381 (this branch is based on
feat/midturn-queue); merge #381 first.Refs #379.
Labels
The author cannot set labels on this repository (
AddLabelsToLabelableis refused forwtz2333):type:feat,area:agent,area:canvas,area:harness.Test plan
pytest tests/test_assistant_steer.py tests/test_assistant_queue.py tests/test_assistant_conversations.py -q→ 41 passedpytest tests/test_native_runtime.py -q→ 25 passed, 5 skipped (the Codex CLI is exercised for real, over the new app-server protocol)pytest tests/test_assistant_retract.py -q→ 3 passed (on the stacked demo branch)lint-imports→ 4 contracts kept;python scripts/generate_contracts.py --check→ verifiedEvidence
Live check on the demo server (real Codex CLI, no mocked stream): first turn streaming →
POST /assistant/messagesdelivery=insert→ 202 withstatus: "inserted"→ same turn finishes and its reply ends with the inserted instruction ((已插入)), stored as:Two failures this transport found
Both only appear against the real binary, which is why they are covered by tests now:
codex app-serverrejects theexec-only--ignore-user-config; the process exited beforeinitializeand the turn failed with "app-server 没有响应". The server now gets a privateCODEX_HOME(project-scoped, onlyauth.jsoncopied), which is the same isolation and keeps the rollout with the project so the next turn can resume it.--model, which the server also rejects (the model travels inturn/start). Codex no longer receives the flag.Frontend
Follows in a separate PR: a running reply offers 「立即插入 / 排队 / 停止」, and the inserted line shows in the conversation as it arrives.
Provider
No provider request is made by these tests beyond the Codex CLI itself; attachments are refused for inserts, so no upload path is exercised.
Bilingual
The API returns Chinese errors like the rest of the assistant routes. UI strings ship with the frontend PR, zh-CN and en-US together.