Loading...
const results = await Promise.all(workers.map((w) => w.run(task)));
return combine(results);const withTimeout = (p) => Promise.race([p, timeout(60_000)]);
const settled = await Promise.allSettled(workers.map((w) => withTimeout(w.run(task))));
const valid = settled
.filter((r) => r.status === 'fulfilled' && isValidResult(r.value))
.map((r) => r.value);
return combine(valid);Timeouts and validation keep one slow or broken worker from blocking or poisoning the combined result.
Not by default. It helps with parallel, separable tasks but uses more tokens and adds coordination failures. Start with one agent.
One orchestrator agent splits the task, sends parts to worker agents, then checks and combines their results.
Usually through the orchestrator, by passing messages or structured results, or through shared files or state.