[feat] assistant: accept a follow-up message while a turn is still running / 运行中插入补充消息
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
Start with the submit guard and conversation state in apps/api/src/opendirector_api/agent.py, then trace RunEvents and the stop path. Read src/backend/chat.ts and src/canvas/useAssistantChat.ts for the client stream and composer flow, plus packages/core/src/opendirector/agent/runtime.py for runtime capabilities. The acceptance criteria define done: queued messages persist, run once in order after the current turn, and remain recoverable across stop, failure, reload, and restart.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Parent roadmap: #261. Related work: edit and resend after stopping #375, conversation management #247, turn/tool/job/receipt correlation #372.
Summary / 摘要
While a reply is streaming, the assistant cannot accept a supplementary instruction. The composer replaces Send with Stop, Enter is silently dropped, and the API answers any second submission for the same project with 409 当前工程已有回复正在执行。. The draft survives, but it cannot be delivered until the turn ends. A user who remembers a missing constraint while the Agent is working must either interrupt the turn (discarding work) or wait and hope the result is not already wrong.
本 issue 描述一个已复现的能力缺口,并提出分层方案:运行中提交的补充消息进入投递队列,当前轮结束后在同一对话里自动续跑(P0,对所有 runtime 生效);在此基础上,对具备原生输入通道的 harness 提供同轮插入(P1,逐个 runtime 实测后再开放)。
Current behavior (verified)
Reproduction: pytest + TestClient, one turn held open through the existing disconnect_turn helper (the run keeps going after the SSE connection closes), then a second submission while active[project_id] is populated. Observed on 9d08bf5a:
PROBE second turn -> 409 {'detail': '当前工程已有回复正在执行。', 'code': 'operation_rejected'}
PROBE draft save -> 200
PROBE messages before/after -> 2 2
PROBE queued markers -> ['complete', 'streaming']
PROBE follow-up routes -> []
| Layer | Location | Behavior |
|---|---|---|
| Submit guard | apps/api/src/opendirector_api/agent.py:291-297 |
POST /turns takes a per-project admission lock, sees project_id in active, raises ProjectError('当前工程已有回复正在执行。', 409) |
| Composer | src/canvas/AssistantPanel.tsx:729-746 |
chat.sending replaces the submit button with the stop button; there is no queued/insert affordance |
| Keyboard | src/canvas/useAssistantChat.ts:436 |
send() returns early while submitting.current is set, so Enter during a turn is a silent no-op |
| Picker state | src/canvas/AssistantPanel.tsx:703,712,719 |
agent, skill and model pickers are disabled while chat.sending |
| Stream shape | src/backend/chat.ts:72-79 |
ChatEvent ends at end; status has complete/streaming/stopped/interrupted, no queued |
| Route surface | apps/api/src/opendirector_api/agent.py |
no queue, retract or follow-up endpoint exists; conversation switching is also refused while running |
| Design statement | docs/architecture/agent-runtime.md |
"同一工程同时只接受一个回复运行" — the single-run guarantee is intentional, not a bug |
The single-run guarantee is worth keeping: it is what keeps runtime sessions, active, the conversation file and the tool ledger consistent. What is missing is a place for input that arrives during a run.
Goal and scope
Let a user submit a supplementary message at any time, and deliver it without losing it, without breaking the single-run guarantee, and with an explicit, inspectable result.
- P0 — queued follow-up, universal. A submission during a run is persisted immediately as a user message in
queuedstate, shown in the conversation, and dispatched as the next turn in the same conversation once the current turn reaches a terminal state. Works for every runtime, including those whose process takes exactly one prompt. - P1 — same-turn steering, per runtime. Where the harness exposes an input channel while it runs (streaming stdin, session server, ACP extension), deliver the text into the running turn and mark it as applied to that turn. Gated on measured capability, not on documentation.
- Out of scope: multi-project parallelism, multi-Agent, reordering or editing the running prompt, and rewriting the runtimes into a duplex protocol.
User flow and rules
- While a turn runs, the composer stays writable and Enter submits. The send action becomes "queue for the next turn" (P0) or offers "insert into this turn" when the runtime declares steering support (P1).
- A queued message appears immediately in the transcript, above the streaming reply's continuation, with a
queuedmarker, its position, and a retract action. Queueing is a commit: the text leaves the draft, and the draft content is preserved in the message. - The running turn keeps its original prompt. A queued message is context for the next turn only, and the next turn sees the finished reply of the previous one. The UI states this, so a user does not believe the current answer already reflects the addition.
- When a turn ends and the queue is non-empty, the next turn starts automatically on the same stream, so the transcript never shows a stopped chain between two turns.
- Multiple queued messages are delivered in submission order, one turn each, unless the user merges them explicitly.
- Stop acts on a chain, not a single turn: stopping cancels the running turn and leaves queued messages in
cancelledstate with a Resend action. Interrupting must never silently consume a supplement. A per-turn continue action is offered separately. - A failed turn stops the chain and keeps the queue intact for an explicit retry. Automatic continuation after an error is not allowed.
- After a process restart, queued messages survive and are offered for continuation instead of being replayed automatically.
- Idempotency: resubmitting the same message id while queued returns the existing queue entry rather than a duplicate or a conflict; the conflict response remains for a message id that is already part of a turn.
- Every state (queued, dispatched, applied to a running turn, cancelled, failed) is visible in the conversation after a reload and through the Agent/CLI entry points.
Implementation impact
Reuse conversation persistence, turn submission, RunEvents replay and the stop path; add the minimum queue record and stream continuation.
- Backend: extend
Conversations(apps/api/src/opendirector_api/agent.py:61) with a per-conversation queue and thequeued/cancelledmessage states; replace the single-turnactiveentry with a chain entry that ownsRunEvents; addPOST /assistant/messages(submit-or-queue),DELETEfor a queued message, a chain-scoped event stream with a replay cursor, and explicit stop scope. - Events: add
seqper chain,messageevents for queue changes, andnextTurnIdonendso a client knows the stream continues instead of treatingendas final. Keep the existingendshape valid for clients that ignore the new fields. - Frontend:
src/canvas/useAssistantChat.ts(submit while running, continue the follower across turns, queue state and retract),src/canvas/AssistantPanel.tsx(composer stays enabled, queued marker and retract, stop semantics),src/backend/chat.ts(event and status types),src/i18n/messages/zh-CN/assistant.tsandsrc/i18n/messages/en-US/assistant.ts(bilingual, delivered together). - Runtime layer: add a declared capability to
RuntimeSpecinpackages/core/src/opendirector/agent/runtime.py(e.g.supportsSteering: bool = False) and surface it throughruntime_catalog()/GET /assistant/runtimes, so the UI never offers an insert the harness cannot honor. No runtime switches to steering without a measured probe.
Acceptance criteria
- Submit during a streaming turn; the text is persisted immediately, visible as
queued, and executed as the next turn after the current one ends, without a second client action. - The running turn receives exactly its original prompt; the next turn receives the queue in order with the previous reply in context.
- Queue two or three messages during one turn; all are delivered exactly once, in order, with no duplicate turn and no lost message.
- Retract a queued message before dispatch; it never reaches a runtime and the transcript shows it as withdrawn.
- Stop during a turn with a queued message; the turn stops, the queued message becomes
cancelled, is not auto-run, and can be resent. - A turn that fails leaves the queue intact for an explicit retry; no automatic continuation.
- Reload, disconnect and process restart preserve queue state and never replay a delivered message.
- Duplicate submission of the same message id produces one queue entry and one turn.
- Steering, where enabled for a runtime, delivers the supplement into the running turn and the reply reflects it; when it is not supported the UI offers queueing instead of failing late.
- Both locales cover every new string, and the UI states whether the supplement applies to this turn or the next.
Decisions to confirm
- Default queue semantics when a turn ends: auto-continue (proposed) versus a visible "continue" prompt.
- Multiple queued messages: one turn per message (proposed) versus coalescing consecutive submissions into the next turn.
- Stop scope: chain-wide with
cancelledqueue entries (proposed) versus turn-only where the queue continues. - Whether a queued message should also be included in a P1 steering-capable turn automatically, or only when the user picks "insert into this turn".
- Linguagem predominante
- TypeScript
- Estrelas
- 119
- Forks
- 16
- Merge médio
- 16h 13min
- PRs com merge (30d)
- 195
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de ThinkFlowLab/OpenDirector
-
area:provider
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
ThinkFlowLab/OpenDirector#477 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
area:ci
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
ThinkFlowLab/OpenDirector#411 ·
Mantenedores costumam responder em até 1 dia
-
[bug] agent: 长素材名在对话气泡中溢出,遮挡正文与素材栏Talvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertaarea:agent
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
ThinkFlowLab/OpenDirector#348 ·
Mantenedores costumam responder em até 1 dia
-
area:provider
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
ThinkFlowLab/OpenDirector#311 ·
Mantenedores costumam responder em até 1 dia
-
area:desktop area:install help wanted
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 25/100
ThinkFlowLab/OpenDirector#475 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de ThinkFlowLab/OpenDirector
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
primer/primitives#1426 ·
-
Sign-in-only setup dialog describes API-key verificationTalvez já em andamento @roboclaw-bot assumiu hoje. Abertaclawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 78/100
openclaw/openclaw#204323 · 1 comentário · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
virtue-initiative/virtue-initiative#953 ·
Mantenedores costumam responder em até 1 dia
-
needs-area-label
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
fumicode/bublys-org#261 ·
Mantenedores costumam responder em até 12 dias