Parallel Execution with Aggregation

orchestrationEasy
Applicability

When to Use

When you need data from multiple independent sources
When latency matters and sequential calls are too slow
When building composite views from multiple services
Overview

How It Works

This pattern executes independent MCP server calls concurrently and combines the results. Using Promise.all() or Promise.allSettled(), the agent fires off multiple requests simultaneously and waits for all to complete. This dramatically reduces latency compared to sequential execution. The aggregation step combines results into a unified structure. Promise.allSettled() is preferred when partial results are acceptable (e.g., a dashboard can show available data even if one source is down).
Implementation

Code Example

typescript
async function getDashboardData(userId) {
  const [user, orders, tickets, activity] = await Promise.allSettled([
    salesforce.getContact({ id: userId }),
    stripe.listCharges({ customer: userId, limit: 10 }),
    zendesk.searchTickets({ query: `requester:${userId}` }),
    analytics.getReport({ filters: [{ dimension: "userId", value: userId }] })
  ]);
  
  return {
    user: user.status === "fulfilled" ? user.value : null,
    recentOrders: orders.status === "fulfilled" ? orders.value.data : [],
    openTickets: tickets.status === "fulfilled" ? tickets.value.length : 0,
    activity: activity.status === "fulfilled" ? activity.value : null,
    errors: [user, orders, tickets, activity].filter(r => r.status === "rejected").map(r => r.reason.message)
  };
}

Quick Info

Categoryorchestration
ComplexityEasy

Need Architecture Help?

Our team designs custom automation architectures.

Get in Touch
CortexAgent Customer Service

Want to skip the form?

Our team is available to help you get started with CortexAgent.

This chat may be recorded for quality assurance. You can view our Privacy Policy.