|
| 1 | +--- |
| 2 | +title: "Multi-Agent Orchestration" |
| 3 | +description: "Launch and coordinate multiple coding agents working in parallel from a single plan." |
| 4 | +--- |
| 5 | + |
| 6 | +import GetHelp from '/snippets/get-help.mdx'; |
| 7 | + |
| 8 | +Multi-agent orchestration lets a Ref agent (the orchestrator) spawn sub-agents on Cursor, Devin, or internal ref-threads, send them messages, and receive updates back — all via MCP tools. This is the most automated way to use Ref Plans. |
| 9 | + |
| 10 | +## How it works |
| 11 | + |
| 12 | +An orchestrator agent reads your plan, then launches child agents to implement and review tasks in parallel. The agents communicate through a parent/child messaging system — no polling required. |
| 13 | + |
| 14 | +```mermaid |
| 15 | +graph TD |
| 16 | + A[Orchestrator Agent] -->|LaunchAgent: cursor| B[Cursor Agent - Task 1] |
| 17 | + A -->|LaunchAgent: devin| C[Devin Agent - Task 2] |
| 18 | + B -->|SendMessage: PR URL| A |
| 19 | + C -->|SendMessage: PR URL| A |
| 20 | + A -->|LaunchAgent: ref-thread| D[Reviewer Agent] |
| 21 | + D -->|SendMessage: Review results| A |
| 22 | +``` |
| 23 | + |
| 24 | +## The tools |
| 25 | + |
| 26 | +Two MCP tools power orchestration: |
| 27 | + |
| 28 | +### LaunchAgent |
| 29 | + |
| 30 | +Launches a sub-agent to work in parallel. Available harness types: |
| 31 | + |
| 32 | +| Harness | Use for | What it does | |
| 33 | +| --- | --- | --- | |
| 34 | +| `cursor` | Implementation tasks | Launches a Cursor background agent that writes code and creates PRs | |
| 35 | +| `devin` | Implementation tasks | Launches a Devin session that writes code and creates PRs | |
| 36 | +| `ref-thread` | Review and lightweight tasks | Launches an internal Ref agent that can read PRs, review diffs, approve, and merge | |
| 37 | + |
| 38 | +Key parameters: |
| 39 | +- **`planIds`** — Plan IDs the agent should be associated with |
| 40 | +- **`prompt`** — The complete task request with all context, requirements, and instructions |
| 41 | +- **`harness`** — Where to run the agent: `cursor`, `devin`, or `ref-thread` |
| 42 | +- **`taskShortDescription`** — Brief label for the agent (~10 words) |
| 43 | +- **`repo`** / **`branch`** / **`model`** — Optional overrides (Cursor only) |
| 44 | + |
| 45 | +### SendMessage |
| 46 | + |
| 47 | +Sends a message between parent and child agents. This is how agents communicate: |
| 48 | + |
| 49 | +- **Child agents** MUST message their parent when work is complete (including the PR URL) or when stuck |
| 50 | +- **Parent agents** use this to send follow-up instructions or course corrections |
| 51 | + |
| 52 | +Parameters: |
| 53 | +- **`agentId`** — The agent to send the message to |
| 54 | +- **`message`** — The message content |
| 55 | + |
| 56 | +## Typical workflow |
| 57 | + |
| 58 | +<Steps> |
| 59 | + <Step title="Plan"> |
| 60 | + Research and iterate on your plan in the web client or via MCP. Break work into tasks that can be implemented independently. |
| 61 | + </Step> |
| 62 | + <Step title="Orchestrate"> |
| 63 | + An orchestrator agent reads the plan and launches implementation agents (Cursor, Devin) in parallel via `LaunchAgent`. Each agent gets a self-contained prompt with all the context it needs. |
| 64 | + </Step> |
| 65 | + <Step title="Review"> |
| 66 | + As implementation agents finish and report back with PR URLs, the orchestrator launches `ref-thread` agents to review each PR. Reviewers have access to GitHub tools (`ReadPR`, `ReviewPR`, `MergePR`) to inspect diffs and approve. |
| 67 | + </Step> |
| 68 | + <Step title="Merge and update"> |
| 69 | + Once reviewers approve, they merge the PRs (if permitted). The orchestrator updates the plan to mark tasks complete. Repeat until the plan is done. |
| 70 | + </Step> |
| 71 | +</Steps> |
| 72 | + |
| 73 | +## Example session |
| 74 | + |
| 75 | +Here's what a typical orchestration session looks like: |
| 76 | + |
| 77 | +1. The orchestrator reads the plan and identifies three independent tasks |
| 78 | +2. It launches two Cursor agents for Task 1 and Task 2 in parallel, and a Devin agent for Task 3 |
| 79 | +3. Task 1's agent finishes first and messages back: *"Task complete. PR: https://github.com/org/repo/pull/42"* |
| 80 | +4. The orchestrator launches a ref-thread reviewer to review PR #42 |
| 81 | +5. Task 2's agent finishes and messages back with its PR URL |
| 82 | +6. The reviewer approves and merges PR #42, then messages the orchestrator with results |
| 83 | +7. The orchestrator updates the plan, marking Task 1 complete |
| 84 | +8. The process continues until all tasks are implemented, reviewed, and merged |
| 85 | + |
| 86 | +## Harness selection guide |
| 87 | + |
| 88 | +**Use `cursor` or `devin` for implementation** — these agents write code, create branches, and open PRs. Choose based on which service you have configured and prefer. |
| 89 | + |
| 90 | +**Use `ref-thread` for reviews** — ref-thread agents have access to GitHub PR tools (`ReadPR`, `ReviewPR`, `MergePR`, `SearchPRs`) that Cursor and Devin agents do not. Always use ref-thread for PR review tasks. |
| 91 | + |
| 92 | +## Requirements |
| 93 | + |
| 94 | +To use multi-agent orchestration, you need: |
| 95 | + |
| 96 | +1. **Ref Plans MCP server installed** in your orchestrating agent — see the [install guide](/plans/install/index) |
| 97 | +2. **Agent orchestration enabled** in [Factory Settings](https://plan.ref.tools/settings) — toggle on the master switch and enable the harnesses you want to use |
| 98 | +3. **API keys configured** for Cursor and/or Devin in [Agent Settings](https://plan.ref.tools/settings) — required for `cursor` and `devin` harnesses |
| 99 | +4. **GitHub connected** at [ref.tools/resources](https://ref.tools/resources) — required for ref-thread reviewers to access PR tools |
| 100 | + |
| 101 | +## Parent/child messaging rules |
| 102 | + |
| 103 | +- Child agents **must** message their parent when done (include the PR URL if one was created) or when stuck |
| 104 | +- Parents can send follow-up instructions or corrections to any child via `SendMessage` |
| 105 | +- Agents can only message their direct parent or their own children — no cross-communication |
| 106 | +- The workflow is message-driven: after launching agents, wait for messages rather than polling |
| 107 | + |
| 108 | +<GetHelp/> |
0 commit comments