Repository navigation
fix(delegation): let queued follow-ups start before delegated sends - #1241
Conversation
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
A plain `thread send` to an idle external Thread with Desktop/Web follow-ups still queued (including a queue paused after Stop) started a Turn ahead of them, and watch notifications used the same path, so they woke a Thread whose queue the user had paused. Such a send now returns THREAD_BUSY, which leaves the next Turn to the queue; watch notifications wait until it has drained. Explicit `--steer true` and `--interrupt` still go ahead of the queue: the registry marks the resend of an interrupt with `interrupt`, so the stopped Thread takes it. Native Codex Threads keep their queue in Desktop and are unaffected.
52f5216 to
7152fc0
Compare
|
感谢贡献!队列优先逻辑语义清晰且无边界隐患,已合入 |
Summary
外部 Harness Thread 空闲、但 Desktop/Web 跟进队列里还有消息时(包括 Stop 或 Turn 失败后处于“队列已暂停”的状态),委派的普通
thread send(CLI、HTTP、MCP)会直接启动一个新 Turn,抢在队列前面。thread watch的通知也走同一条发送路径,因此会越过用户已暂停的队列把 Thread 唤醒,用户排好的跟进消息反而排到 Agent 消息之后。Host 处理 Web 的
turn/start { delivery: "queue" }时,已经有一条规则:队列不为空就把新输入排到队尾。本 PR 让委派发送遵循同一规则:thread send返回THREAD_BUSY,下一轮留给队列。watch 通知按既有重试,等队列清空后再送达。--steer true和--interrupt仍可先于队列开始。注册表在 interrupt 停下 Turn 之后重发消息时带上interrupt,让被停下的 Thread 接受这条消息。文档:
docs/architecture/external-thread-queue.md。Related issues
N/A。#1242(
thread send --mailbox)以本 PR 为前置。UI Demo
No visual changes: 只改 Host 的委派发送路由。
Test plan
npx vitest run --config tests/vitest.config.js packages/host-runtime/test/harness-delegation-coordinator.test.ts packages/host-runtime/test/delegation-interrupt-send.test.ts packages/host-runtime/test/delegation-watch.test.ts:99 个全部通过。THREAD_BUSY;interrupt和steer两种情况都能先于队列开始。interrupt: true。npx tsc -b通过。npx tsc -p tests/tsconfig.json --noEmit报 5 个错误,与当前main上完全相同,位于thread-tree-watch、peer-delegation、peer-thread-links,不涉及本 PR 改动的文件。