feat(cli): add native multi-agent coordination (#8804)

* feat(core): add native multi-agent coordination

* feat(cli): add agent view pty workers

* fix(cli): harden agent view pty workers

* fix(cli): harden agent view pty host teardown

* fix(cli): fail fast on pty host auth rejection

* test(cli): cover pty host remote exit polling

* fix(cli): address agent view pty worker review nits

* fix(cli): harden pty host socket fallback

* fix(cli): harden agent view pty workers

* fix(cli): harden agent view pty workers

* test(cli): cover pty host spawn contract

* fix(cli): guard agent view pty host socket takeover and races

* fix(cli): fit agent view pty logs under wire cap, strip host token after merge

* feat(cli): manage agent view session lifecycle

* fix(cli): preserve agent view lifecycle state

* fix(cli): harden agent view lifecycle persistence

* fix(cli): harden agent view lifecycle

* fix(cli): harden agent view lifecycle recovery

* feat(cli): expose agent view commands

* fix(cli): wire agent view command safeguards

* fix(cli): resolve agent view command integration

* feat(cli): add agent view roster ui

* feat(cli): add durable multi-agent coordination

* fix(cli): harden multi-agent coordination

* fix(cli): complete native coordination flows

* fix(cli): wait for agent view host cold starts

* fix(cli): allow coordination startup time

* fix(cli): persist missing coordination results

* fix(cli): enforce exact Agent View answers

* refactor(cli): reuse existing agent team coordination

* docs(cli): clarify homogeneous coordination

* feat(core): complete native team coordination

* fix(agents): enforce teammate coordination boundaries

* fix(agents): close teammate lifecycle gaps

* fix(agents): align empty teammate names with routing

* fix(core): close coordinator review gaps

* fix(core): keep read-only teammates off writer tasks

---------

Co-authored-by: 俊良 <zzj542558@alibaba-inc.com>
Co-authored-by: qwen-code-ci-bot <qwen-code-ci-bot@users.noreply.github.com>
This commit is contained in:
易良 2026-08-13 01:39:03 +08:00 committed by GitHub
parent 011303239e
commit 8858d4340b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 775 additions and 81 deletions

View file

@ -5,6 +5,7 @@ export default {
'tool-use-summaries': 'Tool-Use Summaries',
'markdown-rendering': 'Markdown Rendering',
'sub-agents': 'SubAgents',
'multi-agent-coordination': 'Multi-Agent Coordination',
arena: 'Agent Arena',
skills: 'Skills',
memory: 'Memory',

View file

@ -200,14 +200,14 @@ Agent Arena is experimental. Current limitations:
## Comparison with other multi-agent modes
Agent Arena is one of several planned multi-agent modes in Qwen Code. **Agent Team** and **Agent Swarm** are not yet implemented — the table below describes their intended design for reference.
Agent Arena and the experimental Agent Team runtime serve different multi-agent workflows. Agent Swarm remains a planned mode.
| | **Agent Arena** | **Agent Team** (planned) | **Agent Swarm** (planned) |
| | **Agent Arena** | **Agent Team** | **Agent Swarm** (planned) |
| :---------------- | :----------------------------------------------------- | :------------------------------------------------- | :------------------------------------------------------- |
| **Goal** | Competitive: Find the best solution to the _same_ task | Collaborative: Tackle _different_ aspects together | Batch parallel: Dynamically spawn workers for bulk tasks |
| **Agents** | Pre-configured models compete independently | Teammates collaborate with assigned roles | Workers spawned on-the-fly, destroyed on completion |
| **Communication** | No inter-agent communication | Direct peer-to-peer messaging | One-way: results aggregated by parent |
| **Isolation** | Full: separate Git worktrees | Independent sessions with shared task list | Lightweight ephemeral context per worker |
| **Isolation** | Full: separate Git worktrees | In-process teammates with a shared task list | Lightweight ephemeral context per worker |
| **Output** | One selected solution applied to workspace | Synthesized results from multiple perspectives | Aggregated results from parallel processing |
| **Best for** | Benchmarking, choosing between model approaches | Research, complex collaboration, cross-layer work | Batch operations, data processing, map-reduce tasks |
@ -216,4 +216,5 @@ Agent Arena is one of several planned multi-agent modes in Qwen Code. **Agent Te
Explore related approaches for parallel and delegated work:
- **Lightweight delegation**: [Subagents](./sub-agents.md) handle focused subtasks within your session — better when you don't need model comparison
- **Collaborative execution**: [Multi-Agent Coordination](./multi-agent-coordination.md) uses Agent Team for shared tasks and teammate messaging
- **Manual parallel sessions**: Run multiple Qwen Code sessions yourself in separate terminals with [Git worktrees](https://git-scm.com/docs/git-worktree) for full manual control

View file

@ -139,12 +139,13 @@ Commands for managing AI tools and models.
These commands invoke bundled skills that provide specialized workflows.
| Command | Description | Usage Examples |
| ------------ | ----------------------------------------------------------- | ------------------------------------------------------------------------- |
| `/review` | Multi-agent code review (12 parallel agents at high effort) | `/review`, `/review 123`, `/review 123 --comment`, `/review --effort low` |
| `/loop` | Run a prompt on a recurring schedule | `/loop 5m check the build` |
| `/simplify` | Review recent changes and apply safe cleanup edits directly | `/simplify`, `/simplify focus on duplication` |
| `/qc-helper` | Answer questions about Qwen Code usage and configuration | `/qc-helper how do I configure MCP?` |
| Command | Description | Usage Examples |
| ------------- | ------------------------------------------------------------- | ------------------------------------------------------------------------- |
| `/review` | Multi-agent code review (12 parallel agents at high effort) | `/review`, `/review 123`, `/review 123 --comment`, `/review --effort low` |
| `/coordinate` | Coordinate read-only workers and one optional worktree writer | `/coordinate investigate and fix the authentication regression` |
| `/loop` | Run a prompt on a recurring schedule | `/loop 5m check the build` |
| `/simplify` | Review recent changes and apply safe cleanup edits directly | `/simplify`, `/simplify focus on duplication` |
| `/qc-helper` | Answer questions about Qwen Code usage and configuration | `/qc-helper how do I configure MCP?` |
See [Code Review](./code-review.md) for full `/review` documentation.

View file

@ -0,0 +1,30 @@
# Multi-Agent Coordination
Qwen Code can coordinate several teammates with the experimental Agent Team runtime. Teammates receive separate tasks, share a task list, exchange messages, and appear in the existing Agent View tabs. `/coordinate` defaults investigation workers to an enforced read-only tool set and can place one writer in a leader-owned Git worktree.
## Enable Agent Team
Set `experimental.agentTeam` to `true` in Qwen Code settings and restart, or start Qwen Code with `QWEN_CODE_ENABLE_AGENT_TEAM=1`.
## Run a coordinated task
Use the bundled skill with a goal:
```text
/coordinate investigate the authentication regression and propose the smallest fix
```
The leader creates a team, assigns up to three independent workstreams, and uses the existing team tools for messages and task state. Teammate conversations and approvals remain visible through the existing Agent View UI. Read-only teammates cannot execute shell commands or write files. If implementation is needed, the leader can create one Git worktree and pin one writer teammate to it; the leader remains the only merge authority for the current branch.
If Agent Team is disabled, `/coordinate` can still use ordinary foreground agents for read-only parallel investigation. That fallback is delegation, not a collaborating team: the workers report only to the leader.
## Choosing the right multi-agent mode
| Mode | Use it for | Communication | Workspace behavior |
| ----------------------------- | --------------------------------------------------------------- | ---------------------------------- | ----------------------------------------------------------- |
| `/coordinate` with Agent Team | Different workstreams contributing to one result | Shared tasks and teammate messages | Enforced read-only workers; optional single worktree writer |
| Subagents | Small delegated tasks | Worker reports to parent | Depends on the selected agent |
| Arena | Several models competing on the same task | Agents do not collaborate | Isolated worktrees; one winner is selected |
| Herdr | Coordinating different CLI products or remote terminal sessions | External terminal-level control | Managed outside Qwen Code |
The current workflow deliberately reuses the in-process Agent Team runtime and Agent View UI. Teammates normally inherit the session model, although an agent definition can override it. Persistent independent PTY sessions, cross-vendor workers, and remote attach are separate product concerns and are not implemented by `/coordinate`.