[BUG] 结束 Orca team 后残留队列消息复活 Lead 状态,阻塞再次 start_team
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 395
- Avg merge
- 21h 48m
- Merged PRs (30d)
- 776
Description
**提交人**: zhaotianyi
**客户端版本**: 0.1.30
---
## 现象
在 Session `600c838c-67fb-4e3c-96d1-f650db1e562b` 中,结束 Orca team 后,Lead 的运行时协同身份被残留队列消息重新注入,造成数据库工作流状态与 MCP context 不一致:
- 2026-08-05 14:22:19(北京时间):日志记录 `disableOrca done`,team 已结束。
- 14:22:44:同一 Lead session 又出现 `send: rehydrate active Orca session with MCP vendorOptions`,且 `usedOrcaInstructions=true`;紧接着输入协调器报告残留队列消息在 dispatch 前被取消。
- 15:40:49:`get_workspace_info` 返回 `workflow: null`、`worker_count: 0`。
- 同一时刻调用 `start_team` 却返回 `ALREADY_ENABLED`,提示“当前 session 已是 Lead”。
- 只能先调用 `end_team` 清理残留状态,再次调用 `start_team` 才成功。
## 复现步骤
1. 在 Lead session 中启动 team 并创建 Worker。
2. Worker 完成或回报时,保留一条 Worker → Lead 的排队消息/自动回报消息。
3. 结束 team,归档 Worker。
4. 在同一 Lead session 中调用 `get_workspace_info`,确认没有 active workflow。
5. 调用 `start_team`。
## 期望行为
结束 team 后,所有 team 范围内的 Worker → Lead 排队消息都应被取消或标记为过期,不能再次触发 Lead session 的 Orca rehydrate。此后:
- `workflow: null` 时,Lead 不应再被识别为 active Orca Lead;
- `start_team` 应能直接创建新的 team;
- 不需要额外调用一次 `end_team` 作为“解锁”操作。
## 实际行为
残留消息触发了 `rehydrateActiveOrcaSession`,重新带入 `orcaRole: lead` / Orca instructions。随后 `get_workspace_info` 读取数据库得到空 workflow,但 `start_team` 在工具层先读取旧的 `vendorOptions.orcaRole`,直接返回 `ALREADY_ENABLED`。
相关实现位置:
- `disableOrcaInternal` 结束 team 时清理 Worker session,但没有确保 Lead 输入队列中的 team 消息全部失效;
- `makerSendTransaction` 会在检测到 Orca 配置时重建 active session;
- `start_team` 在调用 lifecycle service 前以 `vendorOptions.orcaRole === "lead"` 作为阻断条件。
## 验收标准
- [ ] 结束 team 后,残留 Worker → Lead 队列消息不会触发 Orca Lead session 重建或重新派发。
- [ ] 结束 team 后,`get_workspace_info` 与 `start_team` 对同一 session 的状态判断一致。
- [ ] 无 active workflow 时,`start_team` 可以成功创建新 team。
- [ ] 增加覆盖“结束 team → 残留队列消息 → 再次 start_team”的回归测试。
---
**版本区域**: CN
**OS**: darwin arm64 (25.5.0)
**界面语言**: zh-CN
Contributor guide
Research direction
Trace disableOrcaInternal, makerSendTransaction, rehydrateActiveOrcaSession, and the start_team lifecycle check first. Reproduce the end_team → queued Worker-to-Lead message → start_team sequence, then add the regression test described in the acceptance criteria. Done means queued team messages cannot rehydrate the Lead, state checks agree, and start_team succeeds without an extra end_team.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100