parallel-agent-orchestration
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseParallel Agent Orchestration
并行 Agent 编排
Part of Agent Skills™ by googleadsagent.ai™
属于 Agent Skills™ 的一部分,由 googleadsagent.ai™ 提供
Description
概述
Parallel Agent Orchestration is the discipline of dispatching, coordinating, and aggregating results from multiple concurrent subagents to dramatically accelerate complex tasks. Sequential single-agent execution is the default mode for most AI workflows, but it leaves enormous performance on the table. When a task can be decomposed into independent subtasks — analyzing multiple campaigns, reviewing multiple files, searching multiple data sources — parallel dispatch can reduce wall-clock time by 3-10x while maintaining result quality.
This skill encodes the subagent orchestration patterns developed for the Superpowers extension ecosystem and deployed in production at googleadsagent.ai™, where Buddy™ routinely dispatches parallel subagents to analyze different aspects of a Google Ads account simultaneously. One subagent analyzes bidding strategy, another evaluates keyword performance, a third assesses creative quality — all running concurrently. The orchestrator then aggregates their findings into a unified recommendation set, resolving any conflicts between the independent analyses.
The key challenges in parallel orchestration are task partitioning (decomposing the work into truly independent units), result aggregation (combining outputs that may conflict or overlap), resource management (respecting rate limits and cost budgets across parallel agents), and progress monitoring (tracking multiple concurrent streams without losing visibility).
并行 Agent 编排是一项实践,旨在分派、协调并汇总多个并发子 Agent 的结果,从而显著加速复杂任务。大多数 AI 工作流默认采用单 Agent 串行执行,但这种模式会浪费巨大的性能潜力。当任务可以分解为相互独立的子任务——例如分析多个广告系列、审查多个文件或搜索多个数据源——并行分派可以在保持结果质量的同时,将实际耗时缩短 3-10 倍。
本 Skill 编码了为 Superpowers 扩展生态系统开发、且已在 googleadsagent.ai™ 生产环境中部署的子 Agent 编排模式。在该平台上,Buddy™ 经常并行分派子 Agent,同时分析 Google Ads 账户的不同方面。一个子 Agent 分析出价策略,另一个评估关键词表现,第三个评估创意质量——它们会并发运行。随后,编排器将这些发现汇总为一套统一的建议,并解决各项独立分析之间的所有冲突。
并行编排面临的主要挑战包括任务分区(将工作分解为真正独立的工作单元)、结果聚合(合并可能冲突或重叠的输出)、资源管理(在并行 Agent 之间遵守速率限制和成本预算)以及进度监控(跟踪多个并发执行流,同时保持可见性)。
Use When
使用场景
- A task naturally decomposes into 3+ independent subtasks
- Wall-clock time is a critical constraint (user waiting, SLA requirements)
- Multiple data sources or documents need analysis simultaneously
- Code review spans many files that can be reviewed independently
- Batch operations (migrations, refactoring) across multiple files or services
- You need diverse perspectives on the same problem (ensemble reasoning)
- 任务可以自然分解为 3 个以上独立子任务
- 实际耗时是关键约束(用户等待、SLA 要求)
- 需要同时分析多个数据源或文档
- 代码审查涉及多个可以独立审查的文件
- 需要跨多个文件或服务执行批量操作(迁移、重构)
- 需要针对同一问题获得多样化视角(集成推理)
How It Works
工作原理
mermaid
graph TD
A[Complex Task] --> B[Task Decomposer]
B --> C[Subtask 1]
B --> D[Subtask 2]
B --> E[Subtask 3]
B --> F[Subtask N]
C --> G[Subagent 1]
D --> H[Subagent 2]
E --> I[Subagent 3]
F --> J[Subagent N]
G --> K[Result Aggregator]
H --> K
I --> K
J --> K
K --> L{Conflicts?}
L -->|Yes| M[Conflict Resolver]
L -->|No| N[Unified Result]
M --> N
O[Resource Monitor] --> G
O --> H
O --> I
O --> JThe orchestrator receives a complex task and decomposes it into independent subtasks using a task decomposer (either rule-based for well-known patterns or model-assisted for novel tasks). Each subtask is dispatched to a subagent that executes independently, with a resource monitor enforcing shared rate limits and budget constraints. As subagents complete, their results flow to the aggregator, which merges outputs and detects conflicts. Conflicting results (e.g., subagent 1 recommends increasing bids while subagent 2 recommends decreasing them) are resolved by a conflict resolver that applies domain rules or escalates to the orchestrating agent for judgment.
mermaid
graph TD
A[Complex Task] --> B[Task Decomposer]
B --> C[Subtask 1]
B --> D[Subtask 2]
B --> E[Subtask 3]
B --> F[Subtask N]
C --> G[Subagent 1]
D --> H[Subagent 2]
E --> I[Subagent 3]
F --> J[Subagent N]
G --> K[Result Aggregator]
H --> K
I --> K
J --> K
K --> L{Conflicts?}
L -->|Yes| M[Conflict Resolver]
L -->|No| N[Unified Result]
M --> N
O[Resource Monitor] --> G
O --> H
O --> I
O --> J编排器接收复杂任务,并使用任务分解器将其分解为独立子任务;对于已知模式,任务分解器可以使用基于规则的方法,对于新颖任务则可以使用模型辅助方法。每个子任务都会分派给一个独立执行的子 Agent,同时由资源监控器强制执行共享速率限制和预算约束。随着子 Agent 完成工作,其结果会流入聚合器,由聚合器合并输出并检测冲突。冲突结果(例如,子 Agent 1 建议提高出价,而子 Agent 2 建议降低出价)由冲突解决器处理:应用领域规则,或升级给负责编排的 Agent 作出判断。
Implementation
实现
Task Decomposer:
typescript
interface SubTask {
id: string;
description: string;
context: Record<string, unknown>;
dependencies: string[];
priority: number;
}
class TaskDecomposer {
decompose(task: string, context: Record<string, unknown>): SubTask[] {
const patterns: Record<string, (ctx: Record<string, unknown>) => SubTask[]> = {
account_audit: (ctx) => {
const campaigns = ctx.campaigns as string[];
return campaigns.map((campaign, i) => ({
id: `campaign_${i}`,
description: `Analyze campaign: ${campaign}`,
context: { campaign, metrics: ctx.metrics },
dependencies: [],
priority: 1,
}));
},
code_review: (ctx) => {
const files = ctx.changedFiles as string[];
return files.map((file, i) => ({
id: `review_${i}`,
description: `Review changes in ${file}`,
context: { file, diff: ctx.diffs?.[file] },
dependencies: [],
priority: file.includes("test") ? 2 : 1,
}));
},
};
const taskType = this.classifyTask(task);
const decomposer = patterns[taskType];
return decomposer ? decomposer(context) : [{ id: "single", description: task, context, dependencies: [], priority: 1 }];
}
private classifyTask(task: string): string {
if (task.includes("audit") || task.includes("account")) return "account_audit";
if (task.includes("review") || task.includes("PR")) return "code_review";
return "generic";
}
}Parallel Orchestrator:
python
import asyncio
class ParallelOrchestrator:
def __init__(self, max_concurrency=5, budget_limit=None):
self.semaphore = asyncio.Semaphore(max_concurrency)
self.budget_limit = budget_limit
self.total_tokens = 0
self.results = {}
async def execute(self, subtasks: list[dict], agent_factory) -> dict:
dependency_graph = self.build_dependency_graph(subtasks)
ready = [t for t in subtasks if not t["dependencies"]]
pending = [t for t in subtasks if t["dependencies"]]
while ready or pending:
batch_results = await asyncio.gather(*[
self.run_subtask(task, agent_factory) for task in ready
], return_exceptions=True)
for task, result in zip(ready, batch_results):
if isinstance(result, Exception):
self.results[task["id"]] = {"success": False, "error": str(result)}
else:
self.results[task["id"]] = {"success": True, "result": result}
completed_ids = set(self.results.keys())
ready = [t for t in pending if all(d in completed_ids for d in t["dependencies"])]
pending = [t for t in pending if t not in ready]
return self.results
async def run_subtask(self, task: dict, agent_factory):
async with self.semaphore:
if self.budget_limit and self.total_tokens >= self.budget_limit:
raise BudgetExceededError(f"Token budget {self.budget_limit} exceeded")
agent = agent_factory(task)
result = await agent.execute(task["description"], task["context"])
self.total_tokens += result.get("tokens_used", 0)
return result
def build_dependency_graph(self, subtasks):
return {t["id"]: t["dependencies"] for t in subtasks}Result Aggregator with Conflict Resolution:
python
class ResultAggregator:
def aggregate(self, results: dict, strategy: str = "merge") -> dict:
successful = {k: v for k, v in results.items() if v["success"]}
failed = {k: v for k, v in results.items() if not v["success"]}
if strategy == "merge":
merged = self.merge_results(successful)
elif strategy == "vote":
merged = self.majority_vote(successful)
else:
merged = self.concatenate_results(successful)
conflicts = self.detect_conflicts(successful)
if conflicts:
merged = self.resolve_conflicts(merged, conflicts)
return {
"aggregated_result": merged,
"subtask_count": len(results),
"success_count": len(successful),
"failure_count": len(failed),
"conflicts_resolved": len(conflicts),
"failed_tasks": list(failed.keys()),
}
def detect_conflicts(self, results: dict) -> list[dict]:
conflicts = []
recommendations = {}
for task_id, result in results.items():
for rec in result.get("result", {}).get("recommendations", []):
key = rec.get("target")
if key in recommendations:
if recommendations[key]["action"] != rec["action"]:
conflicts.append({
"target": key,
"conflict": [recommendations[key], rec],
"tasks": [recommendations[key]["source"], task_id],
})
recommendations[key] = {**rec, "source": task_id}
return conflicts
def resolve_conflicts(self, merged: dict, conflicts: list) -> dict:
for conflict in conflicts:
higher_confidence = max(conflict["conflict"], key=lambda c: c.get("confidence", 0))
merged["recommendations"] = [
r for r in merged.get("recommendations", [])
if r.get("target") != conflict["target"]
]
merged["recommendations"].append(higher_confidence)
merged.setdefault("conflict_notes", []).append(
f"Conflict on {conflict['target']}: chose {higher_confidence['action']} (confidence: {higher_confidence.get('confidence', 'N/A')})"
)
return merged任务分解器:
typescript
interface SubTask {
id: string;
description: string;
context: Record<string, unknown>;
dependencies: string[];
priority: number;
}
class TaskDecomposer {
decompose(task: string, context: Record<string, unknown>): SubTask[] {
const patterns: Record<string, (ctx: Record<string, unknown>) => SubTask[]> = {
account_audit: (ctx) => {
const campaigns = ctx.campaigns as string[];
return campaigns.map((campaign, i) => ({
id: `campaign_${i}`,
description: `Analyze campaign: ${campaign}`,
context: { campaign, metrics: ctx.metrics },
dependencies: [],
priority: 1,
}));
},
code_review: (ctx) => {
const files = ctx.changedFiles as string[];
return files.map((file, i) => ({
id: `review_${i}`,
description: `Review changes in ${file}`,
context: { file, diff: ctx.diffs?.[file] },
dependencies: [],
priority: file.includes("test") ? 2 : 1,
}));
},
};
const taskType = this.classifyTask(task);
const decomposer = patterns[taskType];
return decomposer ? decomposer(context) : [{ id: "single", description: task, context, dependencies: [], priority: 1 }];
}
private classifyTask(task: string): string {
if (task.includes("audit") || task.includes("account")) return "account_audit";
if (task.includes("review") || task.includes("PR")) return "code_review";
return "generic";
}
}并行编排器:
python
import asyncio
class ParallelOrchestrator:
def __init__(self, max_concurrency=5, budget_limit=None):
self.semaphore = asyncio.Semaphore(max_concurrency)
self.budget_limit = budget_limit
self.total_tokens = 0
self.results = {}
async def execute(self, subtasks: list[dict], agent_factory) -> dict:
dependency_graph = self.build_dependency_graph(subtasks)
ready = [t for t in subtasks if not t["dependencies"]]
pending = [t for t in subtasks if t["dependencies"]]
while ready or pending:
batch_results = await asyncio.gather(*[
self.run_subtask(task, agent_factory) for task in ready
], return_exceptions=True)
for task, result in zip(ready, batch_results):
if isinstance(result, Exception):
self.results[task["id"]] = {"success": False, "error": str(result)}
else:
self.results[task["id"]] = {"success": True, "result": result}
completed_ids = set(self.results.keys())
ready = [t for t in pending if all(d in completed_ids for d in t["dependencies"])]
pending = [t for t in pending if t not in ready]
return self.results
async def run_subtask(self, task: dict, agent_factory):
async with self.semaphore:
if self.budget_limit and self.total_tokens >= self.budget_limit:
raise BudgetExceededError(f"Token budget {self.budget_limit} exceeded")
agent = agent_factory(task)
result = await agent.execute(task["description"], task["context"])
self.total_tokens += result.get("tokens_used", 0)
return result
def build_dependency_graph(self, subtasks):
return {t["id"]: t["dependencies"] for t in subtasks}带冲突解决功能的结果聚合器:
python
class ResultAggregator:
def aggregate(self, results: dict, strategy: str = "merge") -> dict:
successful = {k: v for k, v in results.items() if v["success"]}
failed = {k: v for k, v in results.items() if not v["success"]}
if strategy == "merge":
merged = self.merge_results(successful)
elif strategy == "vote":
merged = self.majority_vote(successful)
else:
merged = self.concatenate_results(successful)
conflicts = self.detect_conflicts(successful)
if conflicts:
merged = self.resolve_conflicts(merged, conflicts)
return {
"aggregated_result": merged,
"subtask_count": len(results),
"success_count": len(successful),
"failure_count": len(failed),
"conflicts_resolved": len(conflicts),
"failed_tasks": list(failed.keys()),
}
def detect_conflicts(self, results: dict) -> list[dict]:
conflicts = []
recommendations = {}
for task_id, result in results.items():
for rec in result.get("result", {}).get("recommendations", []):
key = rec.get("target")
if key in recommendations:
if recommendations[key]["action"] != rec["action"]:
conflicts.append({
"target": key,
"conflict": [recommendations[key], rec],
"tasks": [recommendations[key]["source"], task_id],
})
recommendations[key] = {**rec, "source": task_id}
return conflicts
def resolve_conflicts(self, merged: dict, conflicts: list) -> dict:
for conflict in conflicts:
higher_confidence = max(conflict["conflict"], key=lambda c: c.get("confidence", 0))
merged["recommendations"] = [
r for r in merged.get("recommendations", [])
if r.get("target") != conflict["target"]
]
merged["recommendations"].append(higher_confidence)
merged.setdefault("conflict_notes", []).append(
f"Conflict on {conflict['target']}: chose {higher_confidence['action']} (confidence: {higher_confidence.get('confidence', 'N/A')})"
)
return mergedBest Practices
最佳实践
- Only parallelize truly independent tasks — subtasks that share mutable state or depend on each other's outputs must be sequenced, not parallelized.
- Enforce concurrency limits — unbounded parallelism hits rate limits and inflates costs; cap at 3-5 concurrent subagents for most use cases.
- Set per-subtask and total budgets — prevent runaway costs by limiting tokens per subagent and total tokens across the orchestration.
- Handle partial failures gracefully — if 8 of 10 subagents succeed, aggregate the 8 results rather than failing the entire orchestration.
- Detect and resolve conflicts explicitly — when subagents produce contradictory recommendations, surface the conflict and apply a resolution strategy (confidence-based, majority vote, or escalation).
- Monitor progress in real-time — provide a dashboard or status updates showing which subagents are running, completed, or failed.
- Use the same model tier for parallel subtasks — mixing model tiers within a parallel batch produces inconsistent quality; use a uniform model for comparable results.
- 仅并行化真正独立的任务——共享可变状态或依赖彼此输出的子任务必须串行执行,不能并行化。
- 强制执行并发限制——无界并行会触发速率限制并推高成本;在大多数使用场景中,应将并发子 Agent 数量限制为 3-5 个。
- 设置单子任务预算和总预算——通过限制每个子 Agent 的 token 数量以及整个编排过程的总 token 数量,防止成本失控。
- 妥善处理部分失败——如果 10 个子 Agent 中有 8 个成功,应汇总这 8 个结果,而不是让整个编排失败。
- 显式检测并解决冲突——当子 Agent 给出相互矛盾的建议时,应明确呈现冲突并应用解决策略(基于置信度、多数投票或升级处理)。
- 实时监控进度——提供仪表板或状态更新,显示哪些子 Agent 正在运行、已完成或已失败。
- 并行子任务使用相同的模型档位——在同一并行批次中混用不同模型档位会导致质量不一致;应使用统一模型以获得可比较的结果。
Platform Compatibility
平台兼容性
| Feature | Claude Code | Cursor | Codex | Gemini CLI |
|---|---|---|---|---|
| Subagent dispatch | ✅ Native subagents | ✅ Task tool | ✅ Async tasks | ✅ Async tasks |
| Parallel execution | ✅ Full | ✅ Full | ✅ Full | ✅ Full |
| Concurrency control | ✅ Custom | ✅ Custom | ✅ Custom | ✅ Custom |
| Result aggregation | ✅ Full | ✅ Full | ✅ Full | ✅ Full |
| Progress monitoring | ✅ Status updates | ✅ Background tasks | ✅ Custom | ✅ Custom |
| 功能 | Claude Code | Cursor | Codex | Gemini CLI |
|---|---|---|---|---|
| 子 Agent 分派 | ✅ 原生子 Agent | ✅ Task 工具 | ✅ 异步任务 | ✅ 异步任务 |
| 并行执行 | ✅ 完整支持 | ✅ 完整支持 | ✅ 完整支持 | ✅ 完整支持 |
| 并发控制 | ✅ 自定义 | ✅ 自定义 | ✅ 自定义 | ✅ 自定义 |
| 结果聚合 | ✅ 完整支持 | ✅ 完整支持 | ✅ 完整支持 | ✅ 完整支持 |
| 进度监控 | ✅ 状态更新 | ✅ 后台任务 | ✅ 自定义 | ✅ 自定义 |
Mythos Preview Reference
Mythos Preview 参考
Anthropic’s Mythos Preview workload scales by running many Claude instances in parallel, each focused on a different file so parallel runs explore distinct surface area instead of rediscovering the same issue. Results are then aggregated and de-duplicated downstream (including validation passes).
For orchestration, treat file (or module) boundaries as natural sharding keys, cap concurrency to respect budgets, and standardize an aggregation contract so partial outputs merge cleanly. Source: Mythos Preview.
Anthropic 的 Mythos Preview 通过并行运行大量 Claude 实例来扩展工作负载,每个实例专注于不同的文件,使并行运行探索不同的代码范围,而不是反复发现同一个问题。随后,结果会在下游汇总并去重(包括验证轮次)。
在编排方面,应将文件(或模块)边界视为自然的分片键,限制并发量以遵守预算,并标准化聚合契约,以便部分输出能够顺畅合并。来源:Mythos Preview。
Related Skills
相关 Skill
- Long-Horizon Workflows - Parallel dispatch accelerates individual phases within multi-phase workflows
- Multi-Model Routing - Optimal model selection for parallel subagents balances cost and quality
- Token Optimization - Per-subtask and total budget limits prevent runaway costs in parallel execution
- Google Ads Audit - Multi-campaign audit analysis is a canonical parallel orchestration use case
- Long-Horizon Workflows - 并行分派可以加速多阶段工作流中的各个阶段
- Multi-Model Routing - 为并行子 Agent 选择最优模型,可以在成本与质量之间取得平衡
- Token Optimization - 单子任务和总预算限制可以防止并行执行中的成本失控
- Google Ads Audit - 多广告系列审计分析是并行编排的典型用例
Keywords
关键词
parallel-orchestration, subagents, task-decomposition, result-aggregation, conflict-resolution, concurrency, resource-management, batch-processing, ensemble-reasoning, agent-skills
© 2026 googleadsagent.ai™ | Agent Skills™ | MIT License
parallel-orchestration, subagents, task-decomposition, result-aggregation, conflict-resolution, concurrency, resource-management, batch-processing, ensemble-reasoning, agent-skills
© 2026 googleadsagent.ai™ | Agent Skills™ | MIT License