Skip to content

Adds an agent swarm / multi-agent execution mode to Step-Realtime-CLI, plus related cleanups.#30

Open
Daiyimo wants to merge 29 commits into
stepfun-ai:mainfrom
Daiyimo:main
Open

Adds an agent swarm / multi-agent execution mode to Step-Realtime-CLI, plus related cleanups.#30
Daiyimo wants to merge 29 commits into
stepfun-ai:mainfrom
Daiyimo:main

Conversation

@Daiyimo

@Daiyimo Daiyimo commented Jun 12, 2026

Copy link
Copy Markdown

Closes #61

Main changes

  • Swarm mode plugin (skills/builtin/src/swarm-plugin.ts)
    • State machine (enter / exit / isActive) with dedup by trigger:prompt
    • beforeModelRequest hook injects swarm reminder for top-level main harness only
    • Exposes getSwarmMode() for TUI or other consumers
  • AgentSwarm tool (skills/builtin/src/subagent-plugin.ts)
    • New tool AgentSwarm launches parallel subagents from items + prompt_template
    • Reuses existing BackgroundSubtaskManager
    • Optional subagent_model override per swarm
    • Returns <agent_swarm_result> XML summary
  • Subagent model override
    • AgentHarnessOptions.model now supported
    • Swarm subagents can use a different model than the main agent
  • OpenTUI build flag removed
    • STEP_CLI_ENABLE_OPENTUI gate removed; OpenTUI is always enabled in this build

Tests

  • 9 swarm-mode tests covering state transitions, dedup, and getSwarmMode
  • Fix existing swarm test dedup issue

Docs / chores

  • Update swarm reminder with task_list / task_wait hints
  • Fix formatting in docs/skills/pr-review-decision.md
  • .gitignore ignores `docs/compose/

ZouR-Ma and others added 23 commits June 11, 2026 14:34
…-test-suite

test: add comprehensive test suite (848 tests, 11 files)
…licy

add tests and harden command policy
…install-support

add Windows voice install support
- AGENTS.md §7: state that README.md, README_CN.md, and .gitignore are
  temporarily not accepting modifications, to keep contributors from
  landing parallel edits and creating merge conflicts.
- AGENTS.md §7: link to docs/skills/pr-review-decision.md as the
  reference for maintainer-style PR review (decision rubric, blocker
  checklist, bilingual CN/EN comment templates).
- docs/skills/pr-review-decision.md: new guide. Tool-agnostic; describes
  the workflow from "here's a PR" to "here's the comment to paste."
- .gitignore: ignore .claude/ so per-user agent config doesn't leak in.
* chore: align prettier checks

* fix: preserve smart compaction aborts
…onfig (stepfun-ai#20)

- Add 33 new/enhanced test files covering packages/core, packages/utils,
  packages/realtime, packages/agent-sdk, extensions/*, skills/builtin,
  src/gateway, src/bootstrap, src/commands, src/tui, and integration tests
- Refine vitest.config.ts coverage.include to precisely list tested modules,
  add lcov reporter for CI integration
- Add test:changed script to package.json for incremental test runs
- Fix sox-driver.test.ts for Windows platform guard (upstream PR stepfun-ai#12 compat)
Remove STEP_CLI_ENABLE_OPENTUI env var gate; OpenTUI is now unconditionally enabled.
…ams, remove dead code

- swarm-plugin: add _enterLock mutex to prevent concurrent enter() racing on active state
- swarm-plugin: cap seenPrompts at 1024 with semi-truncation to prevent unbounded growth
- subagent-plugin: replace bare catch in safeFinalize with logger.warn
- subagent-plugin: add 5 AgentSwarm params (context_mode, preset, isolate_workspace, worktree_name, wait_ms)
- subagent-plugin: fix escapeXml to include apostrophe escaping
- swarm-plugin.test: add afterEach cleanup to prevent test state leakage
- open-tui-capability: remove dead parseOpenTuiEnabledValue function
- pr-review-decision: fix Prettier escape artifacts (replace_all, first)

Co-Authored-By: Claude <noreply@anthropic.com>
@ZouR-Ma

ZouR-Ma commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the contribution!

To get this ready to merge:

  • Reference an issue in the description with Closes #<number> (our link-check CI requires it; open one first if needed).
  • Make sure pnpm check passes locally (lint, type-check, dependency/dead-code guards, formatting, and tests — also enforced in CI).

Full conventions:
https://github.com/stepfun-ai/Step-Realtime-CLI/blob/main/CONTRIBUTING.md

- Register createSwarmPlugin() in builtins so beforeModelRequest hook injects swarm reminder
- Add /swarm [on|off|task] slash command with manual/task/tool trigger modes
- Wrap AgentSwarm tool execution with swarmMode.enter('tool')/exit() lifecycle
- Auto-exit swarm mode after turn completes for non-manual triggers
- Fix StepCliInteractiveUiTone import missing from runtime.ts

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added area/build scripts, .github, build/config files area/docs docs, AGENTS.md, README(s), CONTRIBUTING.md area/core packages/core labels Jun 18, 2026
@github-actions github-actions Bot added area/gateway src/gateway area/agent-sdk packages/agent-sdk area/skills skills area/cli src/cli, src/commands, src/runtime, src/bootstrap, src/*.ts area/tui src/tui area/realtime packages/realtime + extensions/realtime-* area/extensions extensions/llm, extensions/mcp (non realtime-*) area/utils packages/utils labels Jun 18, 2026
Daiyimo and others added 3 commits June 18, 2026 15:03
Resolve add/add conflicts in test files and workflows by taking
upstream versions. Our swarm mode changes (runtime.ts, subagent-plugin.ts)
are unaffected.

Co-Authored-By: Claude <noreply@anthropic.com>
The env-var gating in root-command, resume-command, and the
binary-bundle define was left inconsistent after the runtime
layer hard-coded the flag to true. Replace all three with
compile-time true so rolldown can still fold the dead TTY
path, and drop the now-unused define entry.

Co-Authored-By: Claude <noreply@anthropic.com>
本次修复 Step-Realtime-CLI 在 Windows CMD 下通过 setup.ps1 安装后
TUI 无法正常使用的三个 Bug,并附带几项工作区既存的改动。

Bug① TUI 闪退(@opentui/core bun bundle 无法在 Node 加载)
- 根因:@opentui/core 全版本都是 Bun 打包产物(含 bun:ffi),
  Node 的 ESM loader 不支持 bun: 协议,TUI 启动即崩
- 修复:src/commands/root-command.ts 的 shouldUseTui 分支加智能
  respawn——Node 进程 + TUI 路径自动 spawn('bun', ...) 切到 Bun
  子进程;非 TUI 路径仍跑 Node,零影响;靠 process.versions.bun
  判断避免无限循环;Bun 不可用时输出清晰错误并 exit 1

Bug② /swarm 在 TUI 没反应(gateway 级 slash 命令被绕过)
- 根因:TUI 的 handleSlashCommand 本地拦截所有 "/" 输入,但只
  识别少数命令,/swarm 落入 default 显示不明显 "Unknown Command"
  且不清空输入框;gateway 的 executeSlashCommand 只在 REPL 用,
  TUI 模式通过 SDK 通信完全绕过
- 修复:贯穿 gateway/SDK 链新增 executeSlashCommand 转发机制,
  让 TUI 把未识别的 slash 命令回传给 gateway 处理
  - packages/protocol: StepCliSlashCommandResult 接口 + 方法签名
  - src/gateway/runtime.ts: public executeSlashCommandExternal
    (/swarm 特殊处理调 handleSwarmCommand + addEvent)
  - src/gateway/local-gateway.ts + service/session-service.ts: 委托
  - packages/sdk/src/index.ts: SDK 新增 executeSlashCommand
  - src/tui/app.tsx: default case 转发 gateway + submitPromptContent
  - src/tui/slash-commands.ts: /swarm 加入自动补全

Bug③ TUI 滚动失效(Bun setRawMode 不启用 VT 输入标志)
- 根因:Bug① 让 TUI 改跑 Bun 下,但 Bun 的 setRawMode(true) 在
  Windows 上不会启用 ENABLE_VIRTUAL_TERMINAL_INPUT (0x200)——而
  Node 的 libuv 会。没有这个标志 CMD 不把特殊键/鼠标翻译成 VT
  序列,@opentui/core 的 StdinParser 收不到字节,所有滚动空操作
- 修复:新增 src/tui/win-console-input.ts,通过 bun:ffi + kernel32
  的 GetConsoleMode/SetConsoleMode 在 STD_INPUT_HANDLE 补 0x200;
  包装 setRawMode 每次进 raw 模式重新断言;纯增量 OR 不删已有标志
  - src/runtime/local-opentui-entry.tsx: createCliRenderer 前调
    install,后调 ensure 兜底;修正 useAlternateScreen → screenMode
    属性名(CliRendererConfig 用 screenMode,默认 alternate-screen)
  - 降级:非 Windows / 非 Bun / kernel32 不可用 全部 no-op

附带既存改动(工作区预先存在,一并提交):
- 注册 packages/agent-sdk 为 workspace 包
  (package.json、pnpm-workspace.yaml、scripts/build-packages.mjs、
   pnpm-lock.yaml)
- TUI altScreen Windows 兼容:无配置时 Windows 默认 false
  (src/bootstrap/config/loader.ts、src/runtime/runtime-config.ts)

验证:
- pnpm build 通过
- 非 TUI 路径零回归(node bin/step-cli.js --help / --version)
- Bun 基础链路正常(bun bin/step-cli.js --help / --version)
- QA 独立回归验证三个 Bug 修复全 PASS,无跨 Bug 回归
- dist 已同步到 ~/.step-cli/bin/dist/
@github-actions github-actions Bot added area/protocol packages/protocol area/sdk packages/sdk labels Jun 24, 2026
- @step-cli/agent-sdk 被 extensions/realtime-voice 消费,knip 从根 workspace 看不到引用
- rg 是外部系统二进制,非 Node.js 包声明的 binary
@ZouR-Ma

ZouR-Ma commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Status update from the maintainer side — and thanks for the patience on this one. The swarm core itself is solidly engineered: the state machine with dedup, reminder injection scoped to the top-level harness, reuse of the existing BackgroundSubtaskManager, and the accompanying tests all read well.

That said, we want to take proper time to think through the agent swarm / multi-agent execution mode before moving on it. The project already ships AgentTeam (parallel teammates within one turn) and SubAgent, so adding a third parallel-orchestration primitive is a product-level architecture decision — when to reach for swarm vs team, and whether they should converge — and we'd rather settle that deliberately than merge first and untangle later. We're keeping this PR open while it's under consideration; nothing here is lost, and we'll follow up on this thread and in #61 once we've landed on a direction.

In the meantime, if you'd like something that can land quickly, a few focused areas where contributions are very welcome right now:

  • #27 just added an end-to-end test harness for scripts/setup.sh — a second fixture simulating Linux (a shimmed uname reporting Linux) would extend coverage cheaply.
  • The Feishu bridge from #23 has documented follow-ups: replies currently come from the 240-character outputPreview (fetching the full session output would fix truncation in Feishu), the events reconnect doesn't reuse afterEventId, and .feishu-audio-tmp/ files are never cleaned up.
  • The issue tracker has more — anything scoped to one logical change per PR will get a fast review.

Thanks again for the work here — we'll be back on this thread once the orchestration direction is settled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent-sdk packages/agent-sdk area/build scripts, .github, build/config files area/cli src/cli, src/commands, src/runtime, src/bootstrap, src/*.ts area/core packages/core area/docs docs, AGENTS.md, README(s), CONTRIBUTING.md area/extensions extensions/llm, extensions/mcp (non realtime-*) area/gateway src/gateway area/protocol packages/protocol area/realtime packages/realtime + extensions/realtime-* area/sdk packages/sdk area/skills skills area/tui src/tui area/utils packages/utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add /swarm slash command for agent swarm / multi-agent mode

5 participants