Agent Pipeline Orchestration
Overview
Run multi-agent work as a pipeline, not as a batch. Keep implementation, review, QA, and next-phase discovery moving in parallel while the main agent owns planning, boundaries, integration, and final verification. When workers are active, the main agent should not block idly, but should also avoid starting heavy overlapping work that makes returned worker output hard to integrate.
Operating Model
Use the main agent as the tech lead:
- Define the target outcome and current phase.
- Split work into lanes with non-overlapping write scopes.
- Keep one immediate critical-path task local only when delegation would block progress.
- Spawn workers for bounded implementation, reviewers for independent checks, and mappers for next-phase discovery.
- While workers run, fill waiting time with small, reversible, low-conflict tasks.
- Wait for worker output when the next step depends on it, using explicit short wait windows instead of indefinite blocking.
- Review every returned change before treating it as accepted.
- Close completed agents promptly to free capacity.
Lane Types
Keep 3-4 lanes active when capacity allows:
- Implementation lane: scoped code changes with a clear file ownership boundary.
- Review lane: read-only correctness, UX, security, or regression review.
- QA lane: tests, browser checks, visual inspection, or reproduction.
- Mapping lane: read-only discovery for the next feature slice.
Do not let all lanes write the same files. If two tasks need the same files, make one the owner and send follow-up findings to that same agent instead of spawning a competing writer.
Pipeline Loop
State the lanes.
Example: "Backend runtime, frontend shell, media actions, independent review."
Spawn the first lane set.
Give each agent:
- objective
- allowed write paths
- forbidden paths
- tests to run
- expected final report format
Wait briefly, then do light local work.
After spawning workers, wait for the first useful result with a short window, usually 30-90 seconds for implementation or 10-30 seconds for review/mapping. If nothing returns, do light work that is easy to interrupt:
- read or diff files outside worker write scopes
- update progress docs or checklists
- run already-known focused tests
- inspect logs, grep for TODOs, or verify no forbidden paths changed
- prepare the next small prompt
- spawn a read-only reviewer or mapper if capacity is available
Avoid heavy local work while workers own adjacent files. Heavy work includes broad refactors, large architecture changes, implementing the same feature slice, formatting the whole repo, or starting changes whose result will conflict with an active worker.
Check back before starting a new substantial task.
If a worker is still running and the next useful local step is no longer light, wait again for a bounded interval. If the worker still does not return after repeated waits or errors, either narrow the scope and continue locally, or explicitly mark that lane blocked and move to a separate lane.
React to the first returned lane.
When any agent returns:
- read its summary
- inspect the changed files
- run targeted validation if cheap
- send defects back to the same owning agent if it is still open
- close the agent when accepted
- immediately backfill the freed slot with the next non-conflicting task
Feed review findings into implementation lanes.
If a reviewer finds a problem in files owned by an active worker, send the finding to that worker. Spawn a new worker only when the write scope is separate.
Keep capacity useful.
If the agent limit is reached, close completed agents first. Prefer replacing a completed implementation lane with review/QA or next-phase mapping rather than waiting for every lane to finish.
Integrate and verify periodically.
After a coherent slice lands, run focused tests. After several lanes land, run broader checks. Do not postpone all validation to the end.
Waiting Policy
Use waiting intentionally:
- Wait when the next decision depends on an active worker's output.
- Wait after sending a worker defect back, so it has a chance to repair its own write scope.
- Wait before taking over an active worker's task, unless it has errored, timed out repeatedly, or the fix is tiny and clearly non-conflicting.
- Do not wait when there is a clear light task that improves integration without touching worker-owned files.
Suggested rhythm:
- Spawn lanes.
- Wait once for an early return.
- Do one light local task.
- Wait again.
- Review any returned lane.
- Only then start another implementation lane or take over a stalled lane.
This keeps the pipeline non-blocking without turning the main agent into a competing worker.
Delegation Rules
- Delegate only when the user explicitly permits sub-agents or parallel agent work.
- Keep tasks concrete and self-contained.
- Prefer implementation tasks with disjoint write scopes over vague exploration.
- Use read-only mappers for uncertain next steps.
- Use reviewers to audit already-landed changes while implementation continues.
- Do not delegate the immediate blocking step if the main agent can finish it faster and safely.
- Do not duplicate work between main and sub-agents.
- Do not keep coding heavily while waiting for a worker that owns nearby files; prefer bounded waiting plus light integration tasks.
Prompt Template
Use this structure for worker agents:
You are a [role] sub-agent. The main agent owns final review.
Project: [path].
You are not alone in the workspace. Do not revert other changes.
Goal: [specific outcome].
Write scope:
- [allowed files/directories]
Do not modify:
- [forbidden files/directories]
Requirements:
1. [behavior]
2. [behavior]
3. [tests]
Final report:
- changed files
- behavior changes
- validation commands and results
- residual risks
Use this structure for review agents:
Read-only review. Do not modify files.
Review scope: [files/directories].
Find correctness, regression, UX, security, or test gaps.
Report findings by severity with file paths and line numbers.
If no blocker, say so and list residual risks.
Anti-Patterns
Avoid these patterns:
- Blocking on all agents before doing any new work.
- Never waiting for agents and immediately doing their work locally.
- Treating "do not block" as permission to start heavy overlapping changes.
- Spawning multiple writers for the same files.
- Waiting on a mapper before doing unrelated validation.
- Treating sub-agent output as accepted without inspecting changed files.
- Leaving completed agents open and hitting the agent limit.
- Running only implementation lanes with no review or QA lane.
- Sending broad prompts like "continue the feature" without ownership boundaries.
Completion Criteria
Before final response:
- All active implementation agents are either completed and reviewed, or clearly left as pending work.
- Completed agents are closed.
- Relevant focused tests have run.
- Broader validation has run when the slice touched shared contracts.
- The user gets a concise status: completed lanes, validation, residual risks, and next lanes.
1---2name: agent-pipeline-orchestration3description: Manage complex coding or research work as a non-blocking multi-agent pipeline. Use when the user explicitly asks to use sub-agents, multiple agents, delegation, parallel work, a流水线式 workflow, or asks the main agent to manage/review while worker agents implement, review, QA, or map the next phase.4---56# Agent Pipeline Orchestration78## Overview910Run multi-agent work as a pipeline, not as a batch. Keep implementation, review, QA, and next-phase discovery moving in parallel while the main agent owns planning, boundaries, integration, and final verification. When workers are active, the main agent should not block idly, but should also avoid starting heavy overlapping work that makes returned worker output hard to integrate.1112## Operating Model1314Use the main agent as the tech lead:1516- Define the target outcome and current phase.17- Split work into lanes with non-overlapping write scopes.18- Keep one immediate critical-path task local only when delegation would block progress.19- Spawn workers for bounded implementation, reviewers for independent checks, and mappers for next-phase discovery.20- While workers run, fill waiting time with small, reversible, low-conflict tasks.21- Wait for worker output when the next step depends on it, using explicit short wait windows instead of indefinite blocking.22- Review every returned change before treating it as accepted.23- Close completed agents promptly to free capacity.2425## Lane Types2627Keep 3-4 lanes active when capacity allows:2829- Implementation lane: scoped code changes with a clear file ownership boundary.30- Review lane: read-only correctness, UX, security, or regression review.31- QA lane: tests, browser checks, visual inspection, or reproduction.32- Mapping lane: read-only discovery for the next feature slice.3334Do not let all lanes write the same files. If two tasks need the same files, make one the owner and send follow-up findings to that same agent instead of spawning a competing writer.3536## Pipeline Loop37381. State the lanes.39 Example: "Backend runtime, frontend shell, media actions, independent review."40412. Spawn the first lane set.42 Give each agent:43 - objective44 - allowed write paths45 - forbidden paths46 - tests to run47 - expected final report format48493. Wait briefly, then do light local work.50 After spawning workers, wait for the first useful result with a short window, usually 30-90 seconds for implementation or 10-30 seconds for review/mapping. If nothing returns, do light work that is easy to interrupt:51 - read or diff files outside worker write scopes52 - update progress docs or checklists53 - run already-known focused tests54 - inspect logs, grep for TODOs, or verify no forbidden paths changed55 - prepare the next small prompt56 - spawn a read-only reviewer or mapper if capacity is available5758 Avoid heavy local work while workers own adjacent files. Heavy work includes broad refactors, large architecture changes, implementing the same feature slice, formatting the whole repo, or starting changes whose result will conflict with an active worker.59604. Check back before starting a new substantial task.61 If a worker is still running and the next useful local step is no longer light, wait again for a bounded interval. If the worker still does not return after repeated waits or errors, either narrow the scope and continue locally, or explicitly mark that lane blocked and move to a separate lane.62635. React to the first returned lane.64 When any agent returns:65 - read its summary66 - inspect the changed files67 - run targeted validation if cheap68 - send defects back to the same owning agent if it is still open69 - close the agent when accepted70 - immediately backfill the freed slot with the next non-conflicting task71726. Feed review findings into implementation lanes.73 If a reviewer finds a problem in files owned by an active worker, send the finding to that worker. Spawn a new worker only when the write scope is separate.74757. Keep capacity useful.76 If the agent limit is reached, close completed agents first. Prefer replacing a completed implementation lane with review/QA or next-phase mapping rather than waiting for every lane to finish.77788. Integrate and verify periodically.79 After a coherent slice lands, run focused tests. After several lanes land, run broader checks. Do not postpone all validation to the end.8081## Waiting Policy8283Use waiting intentionally:8485- Wait when the next decision depends on an active worker's output.86- Wait after sending a worker defect back, so it has a chance to repair its own write scope.87- Wait before taking over an active worker's task, unless it has errored, timed out repeatedly, or the fix is tiny and clearly non-conflicting.88- Do not wait when there is a clear light task that improves integration without touching worker-owned files.8990Suggested rhythm:91921. Spawn lanes.932. Wait once for an early return.943. Do one light local task.954. Wait again.965. Review any returned lane.976. Only then start another implementation lane or take over a stalled lane.9899This keeps the pipeline non-blocking without turning the main agent into a competing worker.100101## Delegation Rules102103- Delegate only when the user explicitly permits sub-agents or parallel agent work.104- Keep tasks concrete and self-contained.105- Prefer implementation tasks with disjoint write scopes over vague exploration.106- Use read-only mappers for uncertain next steps.107- Use reviewers to audit already-landed changes while implementation continues.108- Do not delegate the immediate blocking step if the main agent can finish it faster and safely.109- Do not duplicate work between main and sub-agents.110- Do not keep coding heavily while waiting for a worker that owns nearby files; prefer bounded waiting plus light integration tasks.111112## Prompt Template113114Use this structure for worker agents:115116```text117You are a [role] sub-agent. The main agent owns final review.118Project: [path].119You are not alone in the workspace. Do not revert other changes.120121Goal: [specific outcome].122123Write scope:124- [allowed files/directories]125126Do not modify:127- [forbidden files/directories]128129Requirements:1301. [behavior]1312. [behavior]1323. [tests]133134Final report:135- changed files136- behavior changes137- validation commands and results138- residual risks139```140141Use this structure for review agents:142143```text144Read-only review. Do not modify files.145Review scope: [files/directories].146Find correctness, regression, UX, security, or test gaps.147Report findings by severity with file paths and line numbers.148If no blocker, say so and list residual risks.149```150151## Anti-Patterns152153Avoid these patterns:154155- Blocking on all agents before doing any new work.156- Never waiting for agents and immediately doing their work locally.157- Treating "do not block" as permission to start heavy overlapping changes.158- Spawning multiple writers for the same files.159- Waiting on a mapper before doing unrelated validation.160- Treating sub-agent output as accepted without inspecting changed files.161- Leaving completed agents open and hitting the agent limit.162- Running only implementation lanes with no review or QA lane.163- Sending broad prompts like "continue the feature" without ownership boundaries.164165## Completion Criteria166167Before final response:168169- All active implementation agents are either completed and reviewed, or clearly left as pending work.170- Completed agents are closed.171- Relevant focused tests have run.172- Broader validation has run when the slice touched shared contracts.173- The user gets a concise status: completed lanes, validation, residual risks, and next lanes.