Skip to content

feat: 蜂群模式(网状)——复刻 Codex Multi-Agent V2 - #98

Merged
shaohaozhi286 merged 3 commits into
masterfrom
worktree-mesh-swarm-v2
Oct 3, 2026
Merged

shaohaozhi286 merged 3 commits into
masterfrom
worktree-mesh-swarm-v2

Conversation

@shaohaozhi286

Copy link
Copy Markdown
Collaborator

概要

新增「蜂群模式(网状)」,复刻 Codex Multi-Agent V2 的 agent 协作树(openspec add-mesh-swarm-mode)。原「蜂群模式」改名为「蜂群模式(星型)」,行为不变。

  • 会话级模式 off | star | mesh:Web 输入框两个互斥菜单项、/swarm star|mesh|off(TUI + daemon 内置命令)、headless --swarm。两套协作工具按模式互斥。
  • 六个 agent_* 工具(spawn / list / send_message / followup_task / wait / interrupt),参数、错误文案与输出对齐 Codex。
  • MeshAgentService:按根会话建树,路径寻址(/root/a/b),每树最多 4 个 agent(含根)+ LRU 换出与按需恢复,完成回报不唤醒空闲父 agent,重启后按 mesh_agents.json 重建。
  • AgentLoop 邮箱:agent 间信封一律入箱,每次模型请求前并入;agent_followup_task 唤醒空闲目标。
  • 界面:agent 间消息在 TUI / Web 显示为系统提示行;后台任务面板复用星型面板并显示 agent 路径。

与 Codex 的有意偏离:信封用 user 角色(Anthropic / DeepSeek 不接受连续 assistant),工具名加 agent_ 前缀。完整说明见 docs/subagents.md §9。

验证

  • acecode_unit_tests fast profile:4920 个通过,0 失败;新增网状集成测试(真实 SessionRegistry + 脚本化 provider:派生、回报、send / followup、LRU 换出与恢复、上限、interrupt、errored、嵌套、退出守卫、重启重建、工具输出契约)
  • 前端 pnpm test(2951 个)、pnpm build、pnpm i18n:audit 通过
  • check_layers / check_ownership / check_file_size、openspec validate --strict 通过
  • 用真实模型(ACEModel-starrylight)在 Web 界面跑通:根 agent 并行派出 3 个子 agent → 回报 → 对其中一个派后续任务 → 汇总

已知未做

  • 后台任务面板按深度缩进、未读计数;来源标签用完整路径
  • 采样中途因新邮件抢占输出、<subagents> 名册、interrupt 后的 <turn_aborted> 标记
  • 帮助页截图 AD-03 需补拍(菜单已是两项)

…(网状)

- 现有蜂群模式改名为蜂群模式(星型),行为不变
- 新增会话级 off/star/mesh 三态、六个 agent_* 协作工具、邮箱投递、驻留换出
- 四份能力规格:swarm-mode-selection / mesh-agent-collaboration / mesh-agent-residency / mesh-agent-observability
- openspec/ 在 .gitignore 中,本目录以 git add -f 纳入跟踪
…ilbox

- domain/session: AgentPath (Codex agent_path.rs rules), SwarmMode with the
  mutually exclusive tool families, inter-agent envelope rendering, swarm_mode
  and mesh_agent.path session metadata
- engine/agent: session-scoped AgentMailbox drained at model boundaries,
  deduplicated mailbox-wake turns, agent_wait activity, envelope transcript rows
- swarm mode moves from a per-turn message flag to the captured request source;
  ToolCapabilityPolicy hides the other tool family with mode-specific refusals
- engine/prompt: mesh role/mode instructions ported from Codex Multi-Agent V2
- MeshAgentService(host/session_host/mesh):按根会话建树,路径寻址、LRU 驻留
  (默认 4 含根)、换出后按需恢复、完成回报(FINAL_ANSWER 不唤醒空闲父,
  interrupted 不回报)、重启后按 mesh_agents.json 重建
- 六个 agent_* 工具(spawn/list/send_message/followup_task/wait/interrupt),
  参数与输出对齐 Codex;与 spawn_subagent / thread 工具按会话模式互斥
- 会话级 swarm_mode(off/star/mesh):消息体、/swarm(TUI + daemon)、headless
  --swarm;退出网状时有运行中 agent 则拒绝;网状子 agent 不接受直接输入
- TUI:SubagentHost 以主会话为外部根接入网状服务,侧栏以路径显示;
  agent 间信封在实时与回放中显示为系统行
- Web:两个互斥菜单项与芯片,芯片跟随服务端模式、只有改选才提交;
  信封转系统提示行;后台任务面板显示 agent 路径
- 测试:网状服务集成测试(真实 SessionRegistry + 脚本化 provider)、
  AgentLoop 邮箱投递、配置 / 命令 / headless / 前端纯逻辑
- 文档:docs/subagents.md §9、daemon-api、帮助页、CLAUDE.md、openspec 实现记录
@shaohaozhi286
shaohaozhi286 merged commit 12f3195 into master Oct 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants