Agentic Design

Patterns
โšก

Parallel Chaining

Executes multiple independent prompts concurrently and intelligently combines their outputs, enabling faster processing and multi-perspective analysis that leverages parallel computation for complex tasks requiring diverse viewpoints or data sources

Complexity: mediumPrompt Chaining

๐ŸŽฏ 30-Second Overview

Pattern: Execute multiple independent tasks concurrently to reduce latency

Why: Drastically reduces wall-clock time for I/O-bound operations, enables multi-perspective analysis

Key Insight: Fan-out independent tasks โ†’ aggregate results with voting/merging/synthesis strategies

โšก Quick Implementation

1Decompose:Identify independent sub-tasks
2Design I/O:Consistent schemas for branches
3Execute:Run branches concurrently
4Aggregate:Vote/merge/synthesize results
5Monitor:Track latency, cost, agreement
Example: search_news AND search_social AND search_web โ†’ aggregate โ†’ synthesize

๐Ÿ“‹ Do's & Don'ts

โœ…Use structured outputs (JSON) for consistent aggregation
โœ…Implement timeouts and partial result handling
โœ…Use smaller models for parallel branches, stronger for merge
โœ…Batch requests and respect rate limits
โœ…Cache results from deterministic branches
โŒParallelize dependent tasks
โŒIgnore rate limits or burst capacity
โŒOver-parallelize simple tasks
โŒSkip error handling for partial failures
โŒUse verbose unstructured data between stages

๐Ÿšฆ When to Use

Use When

  • โ€ข Multiple independent lookups (APIs, DBs)
  • โ€ข Multi-perspective analysis tasks
  • โ€ข I/O-bound operations with latency
  • โ€ข Consensus-building scenarios

Avoid When

  • โ€ข Sequential dependencies exist
  • โ€ข Simple single-step tasks
  • โ€ข Strict rate limits apply
  • โ€ข Consistency > speed requirements

๐Ÿ“Š Key Metrics

Wall-clock Speedup
Time vs sequential baseline
Throughput
Tasks/minute at concurrency
Agreement Score
% consensus among branches
Cost Efficiency
Total tokens ร— model rates
Success Rate
% completed branches
P95 Latency
Tail completion time

๐Ÿ’ก Top Use Cases

Multi-Source Research: news + academic + social โ†’ synthesize findings
Content Generation: headline + body + image + CTA โ†’ complete email
Data Validation: format + business rules + external APIs โ†’ pass/fail
Creative Ideation: 3 models generate options โ†’ select best
Travel Planning: flights + hotels + events + restaurants โ†’ itinerary

References & Further Reading

Deepen your understanding with these curated resources

Contribute to this collection

Know a great resource? Submit a pull request to add it.

Contribute

Patterns

closed

Loading...