Overview

Cookbook

Best-practice workflow patterns with copy-paste code examples.

A curated collection of workflow patterns with clean, copy-paste code examples for real use cases.

Common Patterns

  • Saga — Coordinate multi-step transactions with automatic rollback when a step fails
  • Batching — Process large collections in parallel batches with failure isolation
  • Rate Limiting — Handle 429 responses and transient failures with RetryableError and backoff
  • Fan-Out — Send to multiple channels in parallel with independent failure handling
  • Scheduling — Use durable sleep to schedule actions minutes, hours, or weeks ahead
  • Idempotency — Ensure side effects happen exactly once, even when steps retry
  • Webhooks — Receive HTTP callbacks from external services and process them durably
  • Conditional Routing — Route payloads to different step handlers based on content
  • Child Workflows — Spawn and orchestrate child workflows from a parent

Agent Patterns

  • Durable Agent — Replace a stateless AI agent with one that survives crashes and retries tool calls
  • Tool Streaming — Stream real-time progress updates from tools to the UI
  • Human-in-the-Loop — Pause an agent for human approval, then resume based on the decision
  • Tool Orchestration — Choose between step-level and workflow-level tools, or combine both
  • Stop Workflow — Gracefully cancel a running agent workflow using a hook signal

Integrations

  • AI SDK — Use AI SDK model providers, tool calling, and streaming inside durable workflows
  • Chat SDK — Build durable chat sessions with workflow persistence and AI SDK chat primitives
  • Sandbox — Orchestrate Vercel Sandbox lifecycle inside durable workflows

Advanced

On this page

GitHubEdit this page on GitHub