Skip to main content

Overview

StateGraph provides advanced features for complex workflows:
  • 🔀 Send API - Dynamic parallel execution (orchestrator-worker pattern)
  • Parallel Nodes - Automatic concurrent execution
  • 🎯 Task Decorators - Durable functions with retry and cache

Send API

The Send API enables dynamic parallelization where a node can spawn multiple worker instances that execute concurrently.

Basic Send Pattern

Workers execute in parallel and their results are automatically merged using reducers.

Map-Reduce Pattern

Parallel Node Execution

StateGraph automatically executes nodes in parallel when they have no dependencies:
Automatic Parallelization: When multiple nodes have the same parent and don’t depend on each other, they execute concurrently.

Task Decorator

The @task decorator creates durable functions with built-in retry and caching:

Basic Task

Task with Retry and Cache

Next Steps