9 个本地 Coding Agent 塞进同一个聊天框:单窗口多 Agent 接力的设计拆解
一篇来自掘金的工程实践分享:作者团队在自研 Agent 控制台里实现了「单窗口多 Agent 接力」,让 Codex、Claude Code、Cursor Agent 等 9 个本地 CLI 工具在同一聊天框内无缝切换,免去复制粘贴「交接文档」的人肉传话流程。核心抽象是把 Plan(任务上下文容器)、Agent(本机执行器)、Model(底层大模型)三层分离,任务上下文归 Plan 所有,不绑死在任何 CLI 的私有进程里。 实现上有两个关键机制:一是「统一前台 + 叫号机」,前端只向同一个入口(POST /api/tasks/{taskId}/plan/turn)发消息,后台为每轮分配 turnId「号码牌」,过滤旧轮次的迟到消息,保证中途停止、切换 Agent 时不串台;二是「协议翻译官」,把 9 个接口各异的 CLI 收敛成 3 条通道——Codex 走官方 App Server 专用通道以保留只读沙箱,Claude Code 走 stream-json 通道(结合 --permission-mode plan 与 --resume),其余 Cursor Agent、Grok Build、OpenCode 等 7 个工具统一走开放标准 ACP(Agent Client Protocol)。 文中还演示了一条「登录跳转」需求的完整流转:先用 Codex 啃代码出硬核初稿,切到 Claude Code 推敲业务边界,再切回 Codex 确认测试分支,全程历史讨论与方案正文自动跟随。ACP 被类比为 AI 编程工具界的 Type-C 接口,支持该协议的新工具(如 Gemini CLI)可直接插入,无需重写适配代码。
Current read
如果你也天天在 Codex 和 Claude Code 之间复制粘贴上下文,这篇能省不少事。作者把 9 个 CLI 收敛成 3 条协议通道,靠 turnId 防消息串台,核心是用 ACP 当统一接口。做 Agent 工具链或者想自己搭控制台的开发者,协议选型那段尤其值得抄。
Evidence
11 sourcesConflict check
Dedup data only shows that these sources discuss the same event, not that they agree. There is no structured supporting or refuting evidence yet, so no conflict is inferred automatically.