[feat] assistant: accept a follow-up message while a turn is still running / 运行中插入补充消息
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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".
- 主要言語
- TypeScript
- スター
- 119
- フォーク
- 16
- 平均マージ
- 16時間 13分
- マージ済み PR(30日)
- 195
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ThinkFlowLab/OpenDirector のほかの issue
-
area:provider
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ThinkFlowLab/OpenDirector#477 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area:ci
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ThinkFlowLab/OpenDirector#411 ·
メンテナーはふだん 1 日以内に返信
-
[bug] agent: 长素材名在对话气泡中溢出,遮挡正文与素材栏対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンarea:agent
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
ThinkFlowLab/OpenDirector#348 ·
メンテナーはふだん 1 日以内に返信
-
area:provider
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ThinkFlowLab/OpenDirector#311 ·
メンテナーはふだん 1 日以内に返信
-
area:desktop area:install help wanted
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
ThinkFlowLab/OpenDirector#475 ·
メンテナーはふだん 1 日以内に返信
ThinkFlowLab/OpenDirector の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
primer/primitives#1426 ·
-
Sign-in-only setup dialog describes API-key verification対応中かも @roboclaw-bot が今日担当しました。 オープンclawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
openclaw/openclaw#204323 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
virtue-initiative/virtue-initiative#953 ·
メンテナーはふだん 1 日以内に返信
-
needs-area-label
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
fumicode/bublys-org#261 ·
メンテナーはふだん 12 日以内に返信